diff options
| author | Alex Macleod <alex@macleod.io> | 2023-10-04 18:34:50 +0000 |
|---|---|---|
| committer | Alex Macleod <alex@macleod.io> | 2023-10-05 01:04:41 +0000 |
| commit | 5453a9f34d21bdd1031d58b68fcd6a92adc82108 (patch) | |
| tree | 341eb587ea1a886e92f4104340c1616330753732 /compiler/rustc_errors/src/lib.rs | |
| parent | 2ffeb4636b4ae376f716dc4378a7efb37632dc2d (diff) | |
| download | rust-5453a9f34d21bdd1031d58b68fcd6a92adc82108.tar.gz rust-5453a9f34d21bdd1031d58b68fcd6a92adc82108.zip | |
Add a note to duplicate diagnostics
Diffstat (limited to 'compiler/rustc_errors/src/lib.rs')
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 11 |
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() { |
