Skip to content

Commit

Permalink
Simplify and comment the special-casing for Windows colors
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Dec 8, 2023
1 parent d6fa38a commit 9f0c6f1
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2674,6 +2674,14 @@ fn from_stderr(color: ColorConfig) -> Destination {
}
}

/// On Windows, BRIGHT_BLUE is hard to read on black. Use cyan instead.
///
/// See #36178.
#[cfg(windows)]
const BRIGHT_BLUE: Color = Color::Cyan;
#[cfg(not(windows))]
const BRIGHT_BLUE: Color = Color::Blue;

impl Style {
fn color_spec(&self, lvl: Level) -> ColorSpec {
let mut spec = ColorSpec::new();
Expand All @@ -2688,11 +2696,7 @@ impl Style {
Style::LineNumber => {
spec.set_bold(true);
spec.set_intense(true);
if cfg!(windows) {
spec.set_fg(Some(Color::Cyan));
} else {
spec.set_fg(Some(Color::Blue));
}
spec.set_fg(Some(BRIGHT_BLUE));
}
Style::Quotation => {}
Style::MainHeaderMsg => {
Expand All @@ -2707,11 +2711,7 @@ impl Style {
}
Style::UnderlineSecondary | Style::LabelSecondary => {
spec.set_bold(true).set_intense(true);
if cfg!(windows) {
spec.set_fg(Some(Color::Cyan));
} else {
spec.set_fg(Some(Color::Blue));
}
spec.set_fg(Some(BRIGHT_BLUE));
}
Style::HeaderMsg | Style::NoStyle => {}
Style::Level(lvl) => {
Expand Down

0 comments on commit 9f0c6f1

Please sign in to comment.