Skip to content

Commit 9f0c6f1

Browse files
committed
Simplify and comment the special-casing for Windows colors
1 parent d6fa38a commit 9f0c6f1

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

compiler/rustc_errors/src/emitter.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -2674,6 +2674,14 @@ fn from_stderr(color: ColorConfig) -> Destination {
26742674
}
26752675
}
26762676

2677+
/// On Windows, BRIGHT_BLUE is hard to read on black. Use cyan instead.
2678+
///
2679+
/// See #36178.
2680+
#[cfg(windows)]
2681+
const BRIGHT_BLUE: Color = Color::Cyan;
2682+
#[cfg(not(windows))]
2683+
const BRIGHT_BLUE: Color = Color::Blue;
2684+
26772685
impl Style {
26782686
fn color_spec(&self, lvl: Level) -> ColorSpec {
26792687
let mut spec = ColorSpec::new();
@@ -2688,11 +2696,7 @@ impl Style {
26882696
Style::LineNumber => {
26892697
spec.set_bold(true);
26902698
spec.set_intense(true);
2691-
if cfg!(windows) {
2692-
spec.set_fg(Some(Color::Cyan));
2693-
} else {
2694-
spec.set_fg(Some(Color::Blue));
2695-
}
2699+
spec.set_fg(Some(BRIGHT_BLUE));
26962700
}
26972701
Style::Quotation => {}
26982702
Style::MainHeaderMsg => {
@@ -2707,11 +2711,7 @@ impl Style {
27072711
}
27082712
Style::UnderlineSecondary | Style::LabelSecondary => {
27092713
spec.set_bold(true).set_intense(true);
2710-
if cfg!(windows) {
2711-
spec.set_fg(Some(Color::Cyan));
2712-
} else {
2713-
spec.set_fg(Some(Color::Blue));
2714-
}
2714+
spec.set_fg(Some(BRIGHT_BLUE));
27152715
}
27162716
Style::HeaderMsg | Style::NoStyle => {}
27172717
Style::Level(lvl) => {

0 commit comments

Comments
 (0)