Skip to content

Commit

Permalink
Auto merge of #51485 - estebank:dehighlight-secondary-msgs, r=Guillau…
Browse files Browse the repository at this point in the history
…meGomez

Remove highlighting from secondary messages

Deemphasize the secondary messages so that all other highlights stand
out more.

<img width="684" alt="" src="https://user-images.githubusercontent.com/1606434/41261199-7b4fe96e-6d8f-11e8-8619-04d170617df2.png">
  • Loading branch information
bors committed Jul 21, 2018
2 parents 874dec2 + ed5dcc3 commit 0ad6179
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 0ad6179

Please sign in to comment.