diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 5db5a9a1133d8..4d965c06c914a 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -553,7 +553,12 @@ impl EmitterWriter { code_offset + annotation.start_col, style); } - _ => (), + _ => { + buffer.set_style_range(line_offset, + code_offset + annotation.start_col, + code_offset + annotation.end_col, + Style::Highlight); + } } } diff --git a/src/librustc_errors/styled_buffer.rs b/src/librustc_errors/styled_buffer.rs index ceb94f27dc3ce..d1d5b1b6238a9 100644 --- a/src/librustc_errors/styled_buffer.rs +++ b/src/librustc_errors/styled_buffer.rs @@ -133,4 +133,22 @@ impl StyledBuffer { pub fn num_lines(&self) -> usize { self.text.len() } + + pub fn set_style_range(&mut self, + line: usize, + col_start: usize, + col_end: usize, + style: Style) { + for col in col_start..col_end { + self.set_style(line, col, style); + } + } + + pub fn set_style(&mut self, line: usize, col: usize, style: Style) { + if let Some(ref mut line) = self.styles.get_mut(line) { + if let Some(s) = line.get_mut(col) { + *s = style; + } + } + } }