summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_errors/src/emitter.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_errors/src/emitter.rs')
-rw-r--r--compiler/rustc_errors/src/emitter.rs37
1 files changed, 17 insertions, 20 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs
index 68dba8602..3fb993c36 100644
--- a/compiler/rustc_errors/src/emitter.rs
+++ b/compiler/rustc_errors/src/emitter.rs
@@ -16,8 +16,8 @@ use crate::snippet::{
use crate::styled_buffer::StyledBuffer;
use crate::translation::{to_fluent_args, Translate};
use crate::{
- diagnostic::DiagnosticLocation, CodeSuggestion, Diagnostic, DiagnosticId, DiagnosticMessage,
- FluentBundle, Handler, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
+ diagnostic::DiagnosticLocation, CodeSuggestion, DiagCtxt, Diagnostic, DiagnosticId,
+ DiagnosticMessage, FluentBundle, LazyFallbackBundle, Level, MultiSpan, SubDiagnostic,
SubstitutionHighlight, SuggestionStyle, TerminalUrl,
};
use rustc_lint_defs::pluralize;
@@ -553,10 +553,10 @@ impl Emitter for EmitterWriter {
}
/// An emitter that does nothing when emitting a non-fatal diagnostic.
-/// Fatal diagnostics are forwarded to `fatal_handler` to avoid silent
+/// Fatal diagnostics are forwarded to `fatal_dcx` to avoid silent
/// failures of rustc, as witnessed e.g. in issue #89358.
pub struct SilentEmitter {
- pub fatal_handler: Handler,
+ pub fatal_dcx: DiagCtxt,
pub fatal_note: Option<String>,
}
@@ -581,7 +581,7 @@ impl Emitter for SilentEmitter {
if let Some(ref note) = self.fatal_note {
d.note(note.clone());
}
- self.fatal_handler.emit_diagnostic(&mut d);
+ self.fatal_dcx.emit_diagnostic(d);
}
}
}
@@ -1297,7 +1297,7 @@ impl EmitterWriter {
buffer.append(line_number, line, style_or_override(*style, override_style));
}
} else {
- buffer.append(line_number, &text, style_or_override(*style, override_style));
+ buffer.append(line_number, text, style_or_override(*style, override_style));
}
}
}
@@ -1931,7 +1931,7 @@ impl EmitterWriter {
self.draw_code_line(
&mut buffer,
&mut row_num,
- &highlight_parts,
+ highlight_parts,
line_pos + line_start,
line,
show_code_change,
@@ -2338,7 +2338,7 @@ impl FileWithAnnotatedLines {
let mut output = vec![];
let mut multiline_annotations = vec![];
- if let Some(ref sm) = emitter.source_map() {
+ if let Some(sm) = emitter.source_map() {
for SpanLabel { span, is_primary, label } in msp.span_labels() {
// If we don't have a useful span, pick the primary span if that exists.
// Worst case we'll just print an error at the top of the main file.
@@ -2362,7 +2362,7 @@ impl FileWithAnnotatedLines {
let label = label.as_ref().map(|m| {
normalize_whitespace(
- &emitter.translate_message(m, &args).map_err(Report::new).unwrap(),
+ &emitter.translate_message(m, args).map_err(Report::new).unwrap(),
)
});
@@ -2674,6 +2674,11 @@ fn from_stderr(color: ColorConfig) -> Destination {
}
}
+/// On Windows, BRIGHT_BLUE is hard to read on black. Use cyan instead.
+///
+/// See #36178.
+const BRIGHT_BLUE: Color = if cfg!(windows) { Color::Cyan } else { Color::Blue };
+
impl Style {
fn color_spec(&self, lvl: Level) -> ColorSpec {
let mut spec = ColorSpec::new();
@@ -2688,11 +2693,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 => {
@@ -2707,11 +2708,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) => {
@@ -2719,7 +2716,7 @@ impl Style {
spec.set_bold(true);
}
Style::Highlight => {
- spec.set_bold(true);
+ spec.set_bold(true).set_fg(Some(Color::Magenta));
}
}
spec