diff options
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 12 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 10 |
2 files changed, 18 insertions, 4 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index b153f0f0e82..291920f17f6 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -12,7 +12,7 @@ use Destination::*; use syntax_pos::{SourceFile, Span, MultiSpan}; use crate::{ - Level, CodeSuggestion, Diagnostic, SubDiagnostic, pluralise, + Level, CodeSuggestion, Diagnostic, SubDiagnostic, pluralize, SuggestionStyle, SourceMapper, SourceMapperDyn, DiagnosticId, }; use crate::Level::Error; @@ -424,6 +424,14 @@ impl Emitter for EmitterWriter { } } +/// An emitter that does nothing when emitting a diagnostic. +pub struct SilentEmitter; + +impl Emitter for SilentEmitter { + fn source_map(&self) -> Option<&Lrc<SourceMapperDyn>> { None } + fn emit_diagnostic(&mut self, _: &Diagnostic) {} +} + /// maximum number of lines we will print for each error; arbitrary. pub const MAX_HIGHLIGHT_LINES: usize = 6; /// maximum number of suggestions to be shown @@ -1573,7 +1581,7 @@ impl EmitterWriter { } if suggestions.len() > MAX_SUGGESTIONS { let others = suggestions.len() - MAX_SUGGESTIONS; - let msg = format!("and {} other candidate{}", others, pluralise!(others)); + let msg = format!("and {} other candidate{}", others, pluralize!(others)); buffer.puts(row_num, max_line_num_len + 3, &msg, Style::NoStyle); } else if notice_capitalization { let msg = "notice the capitalization difference"; diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 9743cf0d805..8ee28875c62 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -15,7 +15,6 @@ use Level::*; use emitter::{Emitter, EmitterWriter, is_case_difference}; use registry::Registry; - use rustc_data_structures::sync::{self, Lrc, Lock}; use rustc_data_structures::fx::{FxHashSet, FxIndexMap}; use rustc_data_structures::stable_hasher::StableHasher; @@ -48,6 +47,13 @@ use syntax_pos::{ SpanSnippetError, }; +pub type PResult<'a, T> = Result<T, DiagnosticBuilder<'a>>; + +// `PResult` is used a lot. Make sure it doesn't unintentionally get bigger. +// (See also the comment on `DiagnosticBuilderInner`.) +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16); + /// Indicates the confidence in the correctness of a suggestion. /// /// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion @@ -1027,7 +1033,7 @@ impl Level { } #[macro_export] -macro_rules! pluralise { +macro_rules! pluralize { ($x:expr) => { if $x != 1 { "s" } else { "" } }; |
