about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorRafael Fernández López <ereslibre@ereslibre.es>2018-01-06 13:33:20 +0100
committerRafael Fernández López <ereslibre@ereslibre.es>2018-01-08 17:36:21 +0100
commitb48d944165dd878b887273898b7e4e4b4163c786 (patch)
tree3c1b4c808bc9f63c66fb4643d121bc7851948185 /src/librustc_errors
parent90e019bacd9e5d231e5292b393269ce7ada4940d (diff)
downloadrust-b48d944165dd878b887273898b7e4e4b4163c786.tar.gz
rust-b48d944165dd878b887273898b7e4e4b4163c786.zip
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
https://github.com/rust-lang/rust/pull/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:
https://github.com/rust-lang-nursery/rustfmt/issues/2338

Fixes: https://github.com/rust-lang-nursery/rustfmt/issues/2338
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index c4db39fae86..c48f1761f28 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -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);
     }