Skip to content

Commit 4e2bfe2

Browse files
authored
Rollup merge of #64978 - AnthonyMikh:librustc_errors/lib__fully_clear_inner_handler, r=Mark-Simulacrum
Fully clear `HandlerInner` in `Handler::reset_err_count` Address [`FIXME`](https://github.com/rust-lang/rust/blob/702b45e409495a41afcccbe87a251a692b0cefab/src/librustc_errors/lib.rs#L472) for `Handler::reset_err_count` in the way suggested by @Mark-Simulacrum, i. e. clear all the fields of `HandlerInner`. cc @estebank
2 parents 643ae95 + bd7cd80 commit 4e2bfe2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/librustc_errors/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,17 @@ impl Handler {
469469
/// NOTE: *do not* call this function from rustc. It is only meant to be called from external
470470
/// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as
471471
/// the overall count of emitted error diagnostics.
472-
// FIXME: this does not clear inner entirely
473472
pub fn reset_err_count(&self) {
474473
let mut inner = self.inner.borrow_mut();
475-
// actually frees the underlying memory (which `clear` would not do)
476-
inner.emitted_diagnostics = Default::default();
477-
inner.deduplicated_err_count = 0;
478474
inner.err_count = 0;
479-
inner.stashed_diagnostics.clear();
475+
inner.deduplicated_err_count = 0;
476+
477+
// actually free the underlying memory (which `clear` would not do)
478+
inner.delayed_span_bugs = Default::default();
479+
inner.taught_diagnostics = Default::default();
480+
inner.emitted_diagnostic_codes = Default::default();
481+
inner.emitted_diagnostics = Default::default();
482+
inner.stashed_diagnostics = Default::default();
480483
}
481484

482485
/// Stash a given diagnostic with the given `Span` and `StashKey` as the key for later stealing.

0 commit comments

Comments
 (0)