mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 12:18:33 +00:00
Introduce an option for disabling deduplication of diagnostics
This commit is contained in:
parent
30ddb5a8c1
commit
4feeceecd1
@ -329,6 +329,8 @@ pub struct HandlerFlags {
|
|||||||
/// show macro backtraces even for non-local macros.
|
/// show macro backtraces even for non-local macros.
|
||||||
/// (rustc: see `-Z external-macro-backtrace`)
|
/// (rustc: see `-Z external-macro-backtrace`)
|
||||||
pub external_macro_backtrace: bool,
|
pub external_macro_backtrace: bool,
|
||||||
|
/// If true, identical diagnostics are reported only once.
|
||||||
|
pub deduplicate_diagnostics: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for HandlerInner {
|
impl Drop for HandlerInner {
|
||||||
@ -736,16 +738,16 @@ impl HandlerInner {
|
|||||||
self.emitted_diagnostic_codes.insert(code.clone());
|
self.emitted_diagnostic_codes.insert(code.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let diagnostic_hash = {
|
let already_emitted = |this: &mut Self| {
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
let mut hasher = StableHasher::new();
|
let mut hasher = StableHasher::new();
|
||||||
diagnostic.hash(&mut hasher);
|
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
|
// Only emit the diagnostic if we haven't already emitted an equivalent one.
|
||||||
// one:
|
if !(self.flags.deduplicate_diagnostics && already_emitted(self)) {
|
||||||
if self.emitted_diagnostics.insert(diagnostic_hash) {
|
|
||||||
self.emitter.emit_diagnostic(diagnostic);
|
self.emitter.emit_diagnostic(diagnostic);
|
||||||
if diagnostic.is_error() {
|
if diagnostic.is_error() {
|
||||||
self.deduplicated_err_count += 1;
|
self.deduplicated_err_count += 1;
|
||||||
|
@ -946,4 +946,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
|
|||||||
insert_sideeffect: bool = (false, parse_bool, [TRACKED],
|
insert_sideeffect: bool = (false, parse_bool, [TRACKED],
|
||||||
"fix undefined behavior when a thread doesn't eventually make progress \
|
"fix undefined behavior when a thread doesn't eventually make progress \
|
||||||
(such as entering an empty infinite loop) by inserting llvm.sideeffect"),
|
(such as entering an empty infinite loop) by inserting llvm.sideeffect"),
|
||||||
|
deduplicate_diagnostics: Option<bool> = (None, parse_opt_bool, [UNTRACKED],
|
||||||
|
"deduplicate identical diagnostics"),
|
||||||
}
|
}
|
||||||
|
@ -943,12 +943,11 @@ pub fn build_session_with_source_map(
|
|||||||
let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow);
|
let cap_lints_allow = sopts.lint_cap.map_or(false, |cap| cap == lint::Allow);
|
||||||
|
|
||||||
let can_emit_warnings = !(warnings_allow || cap_lints_allow);
|
let can_emit_warnings = !(warnings_allow || cap_lints_allow);
|
||||||
|
|
||||||
let treat_err_as_bug = sopts.debugging_opts.treat_err_as_bug;
|
let treat_err_as_bug = sopts.debugging_opts.treat_err_as_bug;
|
||||||
let dont_buffer_diagnostics = sopts.debugging_opts.dont_buffer_diagnostics;
|
let dont_buffer_diagnostics = sopts.debugging_opts.dont_buffer_diagnostics;
|
||||||
let report_delayed_bugs = sopts.debugging_opts.report_delayed_bugs;
|
let report_delayed_bugs = sopts.debugging_opts.report_delayed_bugs;
|
||||||
|
|
||||||
let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace;
|
let external_macro_backtrace = sopts.debugging_opts.external_macro_backtrace;
|
||||||
|
let deduplicate_diagnostics = sopts.debugging_opts.deduplicate_diagnostics.unwrap_or(true);
|
||||||
|
|
||||||
let write_dest = match diagnostics_output {
|
let write_dest = match diagnostics_output {
|
||||||
DiagnosticOutput::Default => None,
|
DiagnosticOutput::Default => None,
|
||||||
@ -964,7 +963,7 @@ pub fn build_session_with_source_map(
|
|||||||
report_delayed_bugs,
|
report_delayed_bugs,
|
||||||
dont_buffer_diagnostics,
|
dont_buffer_diagnostics,
|
||||||
external_macro_backtrace,
|
external_macro_backtrace,
|
||||||
..Default::default()
|
deduplicate_diagnostics,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ error: internal compiler error: mutable allocation in constant
|
|||||||
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:345:17
|
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', src/librustc_errors/lib.rs:347:17
|
||||||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
|
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
|
||||||
|
|
||||||
error: internal compiler error: unexpected panic
|
error: internal compiler error: unexpected panic
|
||||||
|
Loading…
Reference in New Issue
Block a user