Skip to content

Commit a484119

Browse files
committed
refactor: Use plain ansi colors for output
1 parent 926d453 commit a484119

19 files changed

+1050
-1058
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::path::Path;
1717
use std::sync::Arc;
1818

1919
use anstream::{AutoStream, ColorChoice};
20-
use anstyle::{Ansi256Color, AnsiColor, Effects};
20+
use anstyle::{AnsiColor, Effects};
2121
use derive_setters::Setters;
2222
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
2323
use rustc_data_structures::sync::{DynSend, IntoDynSyncSend};
@@ -3492,21 +3492,21 @@ pub fn stderr_destination(color: ColorConfig) -> Destination {
34923492
///
34933493
/// See #36178.
34943494
const BRIGHT_BLUE: anstyle::Style = if cfg!(windows) {
3495-
Ansi256Color::from_ansi(AnsiColor::BrightCyan).on_default()
3495+
AnsiColor::BrightCyan.on_default()
34963496
} else {
3497-
Ansi256Color::from_ansi(AnsiColor::BrightBlue).on_default()
3497+
AnsiColor::BrightBlue.on_default()
34983498
};
34993499

35003500
impl Style {
35013501
pub(crate) fn anstyle(&self, lvl: Level) -> anstyle::Style {
35023502
match self {
3503-
Style::Addition => Ansi256Color::from_ansi(AnsiColor::BrightGreen).on_default(),
3504-
Style::Removal => Ansi256Color::from_ansi(AnsiColor::BrightRed).on_default(),
3503+
Style::Addition => AnsiColor::BrightGreen.on_default(),
3504+
Style::Removal => AnsiColor::BrightRed.on_default(),
35053505
Style::LineAndColumn => anstyle::Style::new(),
35063506
Style::LineNumber => BRIGHT_BLUE.effects(Effects::BOLD),
35073507
Style::Quotation => anstyle::Style::new(),
35083508
Style::MainHeaderMsg => if cfg!(windows) {
3509-
Ansi256Color::from_ansi(AnsiColor::BrightWhite).on_default()
3509+
AnsiColor::BrightWhite.on_default()
35103510
} else {
35113511
anstyle::Style::new()
35123512
}

compiler/rustc_errors/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,18 +1966,16 @@ impl fmt::Display for Level {
19661966
impl Level {
19671967
fn color(self) -> anstyle::Style {
19681968
match self {
1969-
Bug | Fatal | Error | DelayedBug => {
1970-
Ansi256Color::from_ansi(AnsiColor::BrightRed).on_default()
1971-
}
1969+
Bug | Fatal | Error | DelayedBug => AnsiColor::BrightRed.on_default(),
19721970
ForceWarning | Warning => {
19731971
if cfg!(windows) {
1974-
Ansi256Color::from_ansi(AnsiColor::BrightYellow).on_default()
1972+
AnsiColor::BrightYellow.on_default()
19751973
} else {
19761974
AnsiColor::Yellow.on_default()
19771975
}
19781976
}
1979-
Note | OnceNote => Ansi256Color::from_ansi(AnsiColor::BrightGreen).on_default(),
1980-
Help | OnceHelp => Ansi256Color::from_ansi(AnsiColor::BrightCyan).on_default(),
1977+
Note | OnceNote => AnsiColor::BrightGreen.on_default(),
1978+
Help | OnceHelp => AnsiColor::BrightCyan.on_default(),
19811979
FailureNote => anstyle::Style::new(),
19821980
Allow | Expect => unreachable!(),
19831981
}

compiler/rustc_errors/src/markdown/term.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::cell::Cell;
22
use std::io::{self, Write};
33

4-
use anstyle::{Ansi256Color, AnsiColor, Effects, Style};
4+
use anstyle::{AnsiColor, Effects, Style};
55

66
use crate::markdown::{MdStream, MdTree};
77

@@ -99,15 +99,9 @@ fn write_tt(
9999
}
100100
MdTree::Heading(n, stream) => {
101101
let cs = match n {
102-
1 => Ansi256Color::from_ansi(AnsiColor::BrightCyan)
103-
.on_default()
104-
.effects(Effects::BOLD | Effects::UNDERLINE),
105-
2 => Ansi256Color::from_ansi(AnsiColor::BrightCyan)
106-
.on_default()
107-
.effects(Effects::UNDERLINE),
108-
3 => Ansi256Color::from_ansi(AnsiColor::BrightCyan)
109-
.on_default()
110-
.effects(Effects::ITALIC),
102+
1 => AnsiColor::BrightCyan.on_default().effects(Effects::BOLD | Effects::UNDERLINE),
103+
2 => AnsiColor::BrightCyan.on_default().effects(Effects::UNDERLINE),
104+
3 => AnsiColor::BrightCyan.on_default().effects(Effects::ITALIC),
111105
4.. => AnsiColor::Cyan.on_default().effects(Effects::UNDERLINE | Effects::ITALIC),
112106
0 => unreachable!(),
113107
};

compiler/rustc_errors/src/markdown/tests/output.stdout

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
H1 Heading ]8;;http://docs.rs\with a link]8;;\
1+
H1 Heading ]8;;http://docs.rs\with a link]8;;\
22
H1 content: some words in bold and so does inline code
33

4-
H2 Heading
4+
H2 Heading
55
H2 content: some words in italic
66

7-
H3 Heading
7+
H3 Heading
88
H3 content: strikethrough text
99

1010
H4 Heading
@@ -24,7 +24,7 @@
2424
elit quam, pulvinar ac risus in, dictum vehicula turpis. Vestibulum neque est, accumsan in cursus sit amet, dictum a nunc. Suspendisse
2525
aliquet, lorem eu eleifend accumsan, magna neque sodales nisi, a aliquet lectus leo eu sem.
2626
--------------------------------------------------------------------------------------------------------------------------------------------
27-
Code
27+
Code
2828
Both inline code and code blocks are supported:
2929

3030
/// A rust enum

tests/ui/argument-suggestions/wrong-highlight-span-extra-arguments-147070.svg

Lines changed: 24 additions & 24 deletions
Loading

0 commit comments

Comments
 (0)