From 5aedef17f975e64c4a012d22af2e151e759d9196 Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Mon, 28 Jul 2025 20:04:48 -0600 Subject: [PATCH] chore: Remove unneeded ansi escape resets from output --- compiler/rustc_errors/src/emitter.rs | 3 +- compiler/rustc_errors/src/markdown/term.rs | 72 +++++++++++-------- .../src/markdown/tests/output.stdout | 46 ++++++------ tests/ui/lint/use_suggestion_json.stderr | 38 +++++----- 4 files changed, 86 insertions(+), 73 deletions(-) diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 33b5ffdeb62f..66a0bfd777a2 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -3408,7 +3408,6 @@ pub(crate) fn emit_to_destination( short_message: bool, ) -> io::Result<()> { use crate::lock; - const RESET: anstyle::Reset = anstyle::Reset; // In order to prevent error message interleaving, where multiple error lines get intermixed // when multiple compiler processes error simultaneously, we emit errors with additional @@ -3426,7 +3425,7 @@ pub(crate) fn emit_to_destination( for (pos, line) in rendered_buffer.iter().enumerate() { for part in line { let style = part.style.anstyle(*lvl); - write!(dst, "{RESET}{style}{}{RESET}", part.text)?; + write!(dst, "{style}{}{style:#}", part.text)?; } if !short_message && (!lvl.is_failure_note() || pos != rendered_buffer.len() - 1) { writeln!(dst)?; diff --git a/compiler/rustc_errors/src/markdown/term.rs b/compiler/rustc_errors/src/markdown/term.rs index 4c5dc86e3859..b0ce01548f00 100644 --- a/compiler/rustc_errors/src/markdown/term.rs +++ b/compiler/rustc_errors/src/markdown/term.rs @@ -6,7 +6,6 @@ use crate::markdown::{MdStream, MdTree}; const DEFAULT_COLUMN_WIDTH: usize = 140; -const RESET: anstyle::Reset = anstyle::Reset; thread_local! { /// Track the position of viewable characters in our buffer @@ -31,53 +30,52 @@ fn write_stream( default: Option