Fix DiagCtxtInner::reset_err_count
.
Several fields were not being reset. Using destructuring makes it much harder to miss a field.
This commit is contained in:
parent
c1ffb0b675
commit
56b451a67a
1 changed files with 44 additions and 14 deletions
|
@ -78,6 +78,7 @@ use std::fmt;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::num::NonZeroUsize;
|
use std::num::NonZeroUsize;
|
||||||
|
use std::ops::DerefMut;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
@ -666,22 +667,51 @@ impl DiagCtxt {
|
||||||
/// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as
|
/// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as
|
||||||
/// the overall count of emitted error diagnostics.
|
/// the overall count of emitted error diagnostics.
|
||||||
pub fn reset_err_count(&self) {
|
pub fn reset_err_count(&self) {
|
||||||
|
// Use destructuring so that if a field gets added to `DiagCtxtInner`, it's impossible to
|
||||||
|
// fail to update this method as well.
|
||||||
let mut inner = self.inner.borrow_mut();
|
let mut inner = self.inner.borrow_mut();
|
||||||
inner.stashed_err_count = 0;
|
let DiagCtxtInner {
|
||||||
inner.deduplicated_err_count = 0;
|
flags: _,
|
||||||
inner.deduplicated_warn_count = 0;
|
err_guars,
|
||||||
inner.must_produce_diag = false;
|
lint_err_guars,
|
||||||
inner.has_printed = false;
|
delayed_bugs,
|
||||||
inner.suppressed_expected_diag = false;
|
stashed_err_count,
|
||||||
|
deduplicated_err_count,
|
||||||
|
deduplicated_warn_count,
|
||||||
|
emitter: _,
|
||||||
|
must_produce_diag,
|
||||||
|
has_printed,
|
||||||
|
suppressed_expected_diag,
|
||||||
|
taught_diagnostics,
|
||||||
|
emitted_diagnostic_codes,
|
||||||
|
emitted_diagnostics,
|
||||||
|
stashed_diagnostics,
|
||||||
|
future_breakage_diagnostics,
|
||||||
|
check_unstable_expect_diagnostics,
|
||||||
|
unstable_expect_diagnostics,
|
||||||
|
fulfilled_expectations,
|
||||||
|
ice_file: _,
|
||||||
|
} = inner.deref_mut();
|
||||||
|
|
||||||
// actually free the underlying memory (which `clear` would not do)
|
// For the `Vec`s and `HashMap`s, we overwrite with an empty container to free the
|
||||||
inner.err_guars = Default::default();
|
// underlying memory (which `clear` would not do).
|
||||||
inner.lint_err_guars = Default::default();
|
*err_guars = Default::default();
|
||||||
inner.delayed_bugs = Default::default();
|
*lint_err_guars = Default::default();
|
||||||
inner.taught_diagnostics = Default::default();
|
*delayed_bugs = Default::default();
|
||||||
inner.emitted_diagnostic_codes = Default::default();
|
*stashed_err_count = 0;
|
||||||
inner.emitted_diagnostics = Default::default();
|
*deduplicated_err_count = 0;
|
||||||
inner.stashed_diagnostics = Default::default();
|
*deduplicated_warn_count = 0;
|
||||||
|
*must_produce_diag = false;
|
||||||
|
*has_printed = false;
|
||||||
|
*suppressed_expected_diag = false;
|
||||||
|
*taught_diagnostics = Default::default();
|
||||||
|
*emitted_diagnostic_codes = Default::default();
|
||||||
|
*emitted_diagnostics = Default::default();
|
||||||
|
*stashed_diagnostics = Default::default();
|
||||||
|
*future_breakage_diagnostics = Default::default();
|
||||||
|
*check_unstable_expect_diagnostics = false;
|
||||||
|
*unstable_expect_diagnostics = Default::default();
|
||||||
|
*fulfilled_expectations = Default::default();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
|
/// Stash a given diagnostic with the given `Span` and [`StashKey`] as the key.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue