Skip to content

Commit

Permalink
Auto merge of rust-lang#47231 - ereslibre:clean-emitted-diagnostics, …
Browse files Browse the repository at this point in the history
…r=nrc

Clean emitted diagnostics when `reset_err_count` is called.

When external tools like `rustfmt` calls to `reset_err_count` for handler
reusing, it will set the error count on the handler to 0, but since
rust-lang#47146 the handler will contain
status that will prevent the error count to be bumped if this handler is
reused.

This caused `rustfmt` idempotency tests to fail:
rust-lang/rustfmt#2338

Fixes: rust-lang/rustfmt#2338
  • Loading branch information
bors committed Jan 9, 2018
2 parents 74966b5 + b48d944 commit 2e33c89
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/librustc_errors/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,13 @@ impl Handler {
self.continue_after_error.set(continue_after_error);
}

// NOTE: DO NOT call this function from rustc, as it relies on `err_count` being non-zero
// if an error happened to avoid ICEs. This function should only be called from tools.
/// Resets the diagnostic error count as well as the cached emitted diagnostics.
///
/// NOTE: DO NOT call this function from rustc. It is only meant to be called from external
/// tools that want to reuse a `Parser` cleaning the previously emitted diagnostics as well as
/// the overall count of emitted error diagnostics.
pub fn reset_err_count(&self) {
self.emitted_diagnostics.replace(FxHashSet());
self.err_count.store(0, SeqCst);
}

Expand Down

0 comments on commit 2e33c89

Please sign in to comment.