Skip to content

Commit a49d3aa

Browse files
committed
refactor: Use plain ansi colors for output
1 parent d990dd6 commit a49d3aa

18 files changed

+1026
-1034
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};
@@ -3485,21 +3485,21 @@ pub fn stderr_destination(color: ColorConfig) -> Destination {
34853485
///
34863486
/// See #36178.
34873487
const BRIGHT_BLUE: anstyle::Style = if cfg!(windows) {
3488-
Ansi256Color::from_ansi(AnsiColor::BrightCyan).on_default()
3488+
AnsiColor::BrightCyan.on_default()
34893489
} else {
3490-
Ansi256Color::from_ansi(AnsiColor::BrightBlue).on_default()
3490+
AnsiColor::BrightBlue.on_default()
34913491
};
34923492

34933493
impl Style {
34943494
pub(crate) fn anstyle(&self, lvl: Level) -> anstyle::Style {
34953495
match self {
3496-
Style::Addition => Ansi256Color::from_ansi(AnsiColor::BrightGreen).on_default(),
3497-
Style::Removal => Ansi256Color::from_ansi(AnsiColor::BrightRed).on_default(),
3496+
Style::Addition => AnsiColor::BrightGreen.on_default(),
3497+
Style::Removal => AnsiColor::BrightRed.on_default(),
34983498
Style::LineAndColumn => anstyle::Style::new(),
34993499
Style::LineNumber => BRIGHT_BLUE.effects(Effects::BOLD),
35003500
Style::Quotation => anstyle::Style::new(),
35013501
Style::MainHeaderMsg => if cfg!(windows) {
3502-
Ansi256Color::from_ansi(AnsiColor::BrightWhite).on_default()
3502+
AnsiColor::BrightWhite.on_default()
35033503
} else {
35043504
anstyle::Style::new()
35053505
}

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/codemap_tests/huge_multispan_highlight.ascii.svg

Lines changed: 38 additions & 38 deletions
Loading

0 commit comments

Comments
 (0)