Skip to content

Commit 601e3da

Browse files
committed
Add reset_err_count() to errors::Handler
The motivation here is to allow rustfmt to recover from parse errors after failing to parse macros.
1 parent f142499 commit 601e3da

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/librustc_errors/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ impl Handler {
303303
self.continue_after_error.set(continue_after_error);
304304
}
305305

306+
// NOTE: DO NOT call this function from rustc, as it relies on `err_count` being non-zero
307+
// if an error happened to avoid ICEs. This function should only be called from tools.
308+
pub fn reset_err_count(&self) {
309+
self.err_count.set(0);
310+
}
311+
306312
pub fn struct_dummy<'a>(&'a self) -> DiagnosticBuilder<'a> {
307313
DiagnosticBuilder::new(self, Level::Cancelled, "")
308314
}

0 commit comments

Comments
 (0)