Skip to content

Commit

Permalink
Remove highlighting from secondary messages
Browse files Browse the repository at this point in the history
Deemphasize the secondary messages so that all other highlights stand
out more.
  • Loading branch information
estebank committed Jun 11, 2018
1 parent ae0659c commit ed5dcc3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,11 @@ impl EmitterWriter {
is_secondary: bool)
-> io::Result<()> {
let mut buffer = StyledBuffer::new();
let header_style = if is_secondary {
Style::HeaderMsg
} else {
Style::MainHeaderMsg
};

if msp.primary_spans().is_empty() && msp.span_labels().is_empty() && is_secondary
&& !self.short_message {
Expand All @@ -973,7 +978,7 @@ impl EmitterWriter {
draw_note_separator(&mut buffer, 0, max_line_num_len + 1);
let level_str = level.to_string();
if !level_str.is_empty() {
buffer.append(0, &level_str, Style::HeaderMsg);
buffer.append(0, &level_str, Style::MainHeaderMsg);
buffer.append(0, ": ", Style::NoStyle);
}
self.msg_to_buffer(&mut buffer, msg, max_line_num_len, "note", None);
Expand All @@ -989,10 +994,10 @@ impl EmitterWriter {
buffer.append(0, "]", Style::Level(level.clone()));
}
if !level_str.is_empty() {
buffer.append(0, ": ", Style::HeaderMsg);
buffer.append(0, ": ", header_style);
}
for &(ref text, _) in msg.iter() {
buffer.append(0, text, Style::HeaderMsg);
buffer.append(0, text, header_style);
}
}

Expand Down Expand Up @@ -1521,7 +1526,7 @@ impl<'a> WritableDst<'a> {
}
}
Style::Quotation => {}
Style::OldSchoolNoteText | Style::HeaderMsg => {
Style::OldSchoolNoteText | Style::MainHeaderMsg => {
spec.set_bold(true);
if cfg!(windows) {
spec.set_intense(true)
Expand All @@ -1542,6 +1547,7 @@ impl<'a> WritableDst<'a> {
spec.set_fg(Some(Color::Blue));
}
}
Style::HeaderMsg |
Style::NoStyle => {}
Style::Level(lvl) => {
spec = lvl.color();
Expand Down
1 change: 1 addition & 0 deletions src/librustc_errors/snippet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ pub struct StyledString {

#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
pub enum Style {
MainHeaderMsg,
HeaderMsg,
LineAndColumn,
LineNumber,
Expand Down

0 comments on commit ed5dcc3

Please sign in to comment.