Skip to content

Commit 7a03b4c

Browse files
committed
Fix unexpected panic with the -Z treat-err-as-bug option
This fix an issue where the compiler panics even if there is no error when passed with the `-Z treat-err-as-bug` option. Fixes rust-lang#35886.
1 parent e19ccb7 commit 7a03b4c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/librustc_errors/diagnostic_builder.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ impl<'a> DiagnosticBuilder<'a> {
9999

100100
self.handler.emitter.borrow_mut().emit(&self);
101101
self.cancel();
102-
self.handler.panic_if_treat_err_as_bug();
102+
103+
if self.level == Level::Error {
104+
self.handler.panic_if_treat_err_as_bug();
105+
}
103106

104107
// if self.is_fatal() {
105108
// panic!(FatalError);

0 commit comments

Comments
 (0)