about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2017-08-29 21:40:54 +0000
committerGitHub <noreply@github.com>2017-08-29 21:40:54 +0000
commit64a21f875f37ab0184a79e44e311f25e8e99dd86 (patch)
tree9be65c3feb02dcaf0542d4ec54a872720d18dd85 /src/librustc_errors
parent11e75fd1150daafb39e769d6df2db73062edef06 (diff)
parent601e3dac6cd71bf657c04fceb868540031e6db95 (diff)
Rollup merge of #43778 - topecongiro:handler-reset-err-count, r=arielb1
Add reset_err_count() to errors::Handler

The motivation here is to allow rustfmt to recover from parse errors after failing to parse macros (cc https://github.com/rust-lang-nursery/rustfmt/issues/1742).
r? @nrc
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 870bb01bb9f..2c756be02f1 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -306,6 +306,12 @@ 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.
+    pub fn reset_err_count(&self) {
+        self.err_count.set(0);
+    }
+
     pub fn struct_dummy<'a>(&'a self) -> DiagnosticBuilder<'a> {
         DiagnosticBuilder::new(self, Level::Cancelled, "")
     }