about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-01-04 18:39:14 +0000
committerbors <bors@rust-lang.org>2020-01-04 18:39:14 +0000
commit760ce94c69ca510d44087291c311296f6d9ccdf5 (patch)
treea1268072a6fad12c2758f30c8409adb3ea087c20 /src/librustc_errors
parentcd8377d37e9bc47f9a5a982c41705a7800cbb51d (diff)
parent0bbe11089ccdb575d3f7d5a6c83eb3d2810eef29 (diff)
downloadrust-760ce94c69ca510d44087291c311296f6d9ccdf5.tar.gz
rust-760ce94c69ca510d44087291c311296f6d9ccdf5.zip
Auto merge of #67874 - Dylan-DPC:rollup-xy6bkoe, r=Dylan-DPC
Rollup of 4 pull requests

Successful merges:

 - #67137 (libstd uses `core::panic::Location` where possible.)
 - #67709 (Introduce an option for disabling deduplication of diagnostics)
 - #67775 (Make "use $crate" a hard error)
 - #67812 (Tweak and extend internal BTreeMap documentation, including debug asserts.)

Failed merges:

r? @ghost
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index aa2865a75f9..2279ed85954 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,17 @@ 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've been asked to deduplicate and
+        // haven't already emitted an equivalent diagnostic.
+        if !(self.flags.deduplicate_diagnostics && already_emitted(self)) {
             self.emitter.emit_diagnostic(diagnostic);
             if diagnostic.is_error() {
                 self.deduplicated_err_count += 1;