diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-01-04 23:52:48 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-04 23:52:48 +0530 |
| commit | 3c87772a8a4f00cfcce26615ae7808f278c61c44 (patch) | |
| tree | 400cb52b902d96f7be1ea66eeea50cb63ba37ba8 /src/librustc_errors | |
| parent | cce055daef93bfa50b11b1d3368811fe586d8a42 (diff) | |
| parent | 5bf810599306fd880b0946ecb3e1ec37ca72762f (diff) | |
| download | rust-3c87772a8a4f00cfcce26615ae7808f278c61c44.tar.gz rust-3c87772a8a4f00cfcce26615ae7808f278c61c44.zip | |
Rollup merge of #67709 - petrochenkov:nodedup2, r=Centril
Introduce an option for disabling deduplication of diagnostics With the intent of using it in UI tests (https://github.com/rust-lang/rust/pull/67122). The option is boolean (`-Z deduplicate-diagnostics=yes/no`) and can be specified multiple times with later values overriding earlier values (`-Z deduplicate-diagnostics=no -Z deduplicate-diagnostics=yes` == `-Z deduplicate-diagnostics=yes`), so it can be set in a hierarchical way, e.g. UI testing infra may disable the deduplication by default with specific tests being able to enable it back.
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/lib.rs | 13 |
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; |
