From 4feeceecd14d41cb74d10f15933aba3acdd6cc91 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Sun, 29 Dec 2019 22:10:47 +0300 Subject: Introduce an option for disabling deduplication of diagnostics --- src/librustc_errors/lib.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/librustc_errors') 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; -- cgit 1.4.1-3-g733a5