about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorStefan Lankes <slankes@eonerc.rwth-aachen.de>2019-11-13 00:24:37 +0100
committerStefan Lankes <slankes@eonerc.rwth-aachen.de>2019-11-13 00:24:37 +0100
commit88717319142e162ae2f48124d94f33d2c21bc2ce (patch)
treee50a968f836c55007e9bc8f305d4f0f80aca042c /src/librustc_errors
parent969b74144641bf1c8ae5aba0581f4b52a4c15bac (diff)
parent4f03f4a989d1c8346c19dfb417a77c09b34408b8 (diff)
downloadrust-88717319142e162ae2f48124d94f33d2c21bc2ce.tar.gz
rust-88717319142e162ae2f48124d94f33d2c21bc2ce.zip
Merge remote-tracking branch 'rust-lang/master' into hermit
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/emitter.rs12
-rw-r--r--src/librustc_errors/lib.rs10
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 { "" }
     };