Skip to content

Commit 29077e8

Browse files
author
Jonathan Turner
authored
Rollup merge of rust-lang#36178 - jonathandturner:windows_colors, r=nikomatsakis
Special case a few colors for Windows As brought up on [this thread](rust-lang#33240 (comment)) the colors used in error messages on Windows can be difficult to read because of the lack of bold. This PR makes a few changes to improve readability, namely: * Rather than using BRIGHT_BLUE, on Windows we now use BRIGHT_CYAN, which is easier to read on black when you do not have bold * We used BRIGHT_YELLOW rather than YELLOW, for the same reason * Titles will be BRIGHT_WHITE now, to give the illusion of being bold Some examples: ![warning](https://cloud.githubusercontent.com/assets/547158/18148466/9aa9bbe2-6f8e-11e6-927f-d0eec53cac32.PNG) ![error](https://cloud.githubusercontent.com/assets/547158/18148488/ba9fb186-6f8e-11e6-8d8e-e93d569f61de.PNG) r? @nikomatsakis cc @retep998
2 parents 0bbc6ec + 1b04762 commit 29077e8

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/librustc_errors/emitter.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,11 @@ impl Destination {
883883
Style::FileNameStyle | Style::LineAndColumn => {}
884884
Style::LineNumber => {
885885
try!(self.start_attr(term::Attr::Bold));
886-
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
886+
if cfg!(windows) {
887+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_CYAN)));
888+
} else {
889+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
890+
}
887891
}
888892
Style::ErrorCode => {
889893
try!(self.start_attr(term::Attr::Bold));
@@ -896,6 +900,9 @@ impl Destination {
896900
}
897901
Style::OldSchoolNoteText | Style::HeaderMsg => {
898902
try!(self.start_attr(term::Attr::Bold));
903+
if cfg!(windows) {
904+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_WHITE)));
905+
}
899906
}
900907
Style::UnderlinePrimary | Style::LabelPrimary => {
901908
try!(self.start_attr(term::Attr::Bold));
@@ -904,7 +911,11 @@ impl Destination {
904911
Style::UnderlineSecondary |
905912
Style::LabelSecondary => {
906913
try!(self.start_attr(term::Attr::Bold));
907-
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
914+
if cfg!(windows) {
915+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_CYAN)));
916+
} else {
917+
try!(self.start_attr(term::Attr::ForegroundColor(term::color::BRIGHT_BLUE)));
918+
}
908919
}
909920
Style::NoStyle => {}
910921
Style::Level(l) => {

src/librustc_errors/lib.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,13 @@ impl Level {
732732
pub fn color(self) -> term::color::Color {
733733
match self {
734734
Bug | Fatal | PhaseFatal | Error => term::color::BRIGHT_RED,
735-
Warning => term::color::YELLOW,
735+
Warning => {
736+
if cfg!(windows) {
737+
term::color::BRIGHT_YELLOW
738+
} else {
739+
term::color::YELLOW
740+
}
741+
},
736742
Note => term::color::BRIGHT_GREEN,
737743
Help => term::color::BRIGHT_CYAN,
738744
Cancelled => unreachable!(),

0 commit comments

Comments
 (0)