about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-10-05 19:24:35 +0200
committerGitHub <noreply@github.com>2023-10-05 19:24:35 +0200
commitc1c5ab717efbaf277869616d585aca8de3e47d73 (patch)
tree6e6cc0107096fd32bf119d177e0ec19768509d6d /compiler/rustc_errors/src
parent08cc7428d9c681ca5fbd90d0fb70662e9b95d781 (diff)
parent5453a9f34d21bdd1031d58b68fcd6a92adc82108 (diff)
downloadrust-c1c5ab717efbaf277869616d585aca8de3e47d73.tar.gz
rust-c1c5ab717efbaf277869616d585aca8de3e47d73.zip
Rollup merge of #116428 - Alexendoo:note-duplicate-diagnostics, r=compiler-errors,estebank
Add a note to duplicate diagnostics

Helps explain why there may be a difference between manual testing and the test suite output and highlights them as something to potentially look into

For existing duplicate diagnostics I just blessed them other than a few files that had other `NOTE` annotations in
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/lib.rs11
1 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index b747a62b864..665b5d6adec 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -1376,16 +1376,16 @@ impl HandlerInner {
                 self.emitted_diagnostic_codes.insert(code.clone());
             }
 
-            let already_emitted = |this: &mut Self| {
+            let already_emitted = {
                 let mut hasher = StableHasher::new();
                 diagnostic.hash(&mut hasher);
                 let diagnostic_hash = hasher.finish();
-                !this.emitted_diagnostics.insert(diagnostic_hash)
+                !self.emitted_diagnostics.insert(diagnostic_hash)
             };
 
             // Only emit the diagnostic if we've been asked to deduplicate or
             // haven't already emitted an equivalent diagnostic.
-            if !(self.flags.deduplicate_diagnostics && already_emitted(self)) {
+            if !(self.flags.deduplicate_diagnostics && already_emitted) {
                 debug!(?diagnostic);
                 debug!(?self.emitted_diagnostics);
                 let already_emitted_sub = |sub: &mut SubDiagnostic| {
@@ -1401,6 +1401,11 @@ impl HandlerInner {
                 };
 
                 diagnostic.children.extract_if(already_emitted_sub).for_each(|_| {});
+                if already_emitted {
+                    diagnostic.note(
+                        "duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`",
+                    );
+                }
 
                 self.emitter.emit_diagnostic(diagnostic);
                 if diagnostic.is_error() {