about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-12-29 22:10:47 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2020-01-03 18:03:28 +0400
commit4feeceecd14d41cb74d10f15933aba3acdd6cc91 (patch)
tree4f055f83b1e50b99e36df45f59beccb8f48c4a42 /src/librustc_errors
parent30ddb5a8c1e85916da0acdc665d6a16535a12dd6 (diff)
downloadrust-4feeceecd14d41cb74d10f15933aba3acdd6cc91.tar.gz
rust-4feeceecd14d41cb74d10f15933aba3acdd6cc91.zip
Introduce an option for disabling deduplication of diagnostics
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index aa2865a75f9..999c3470e71 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -329,6 +329,8 @@ pub struct HandlerFlags {
     /// show macro backtraces even for non-local macros.
     /// (rustc: see `-Z external-macro-backtrace`)
     pub external_macro_backtrace: bool,
+    /// If true, identical diagnostics are reported only once.
+    pub deduplicate_diagnostics: bool,
 }
 
 impl Drop for HandlerInner {
@@ -736,16 +738,16 @@ impl HandlerInner {
             self.emitted_diagnostic_codes.insert(code.clone());
         }
 
-        let diagnostic_hash = {
+        let already_emitted = |this: &mut Self| {
             use std::hash::Hash;
             let mut hasher = StableHasher::new();
             diagnostic.hash(&mut hasher);
-            hasher.finish()
+            let diagnostic_hash = hasher.finish();
+            !this.emitted_diagnostics.insert(diagnostic_hash)
         };
 
-        // Only emit the diagnostic if we haven't already emitted an equivalent
-        // one:
-        if self.emitted_diagnostics.insert(diagnostic_hash) {
+        // Only emit the diagnostic if we haven't already emitted an equivalent one.
+        if !(self.flags.deduplicate_diagnostics && already_emitted(self)) {
             self.emitter.emit_diagnostic(diagnostic);
             if diagnostic.is_error() {
                 self.deduplicated_err_count += 1;