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 #35886.
This commit is contained in:
Tommy Ip 2017-05-12 12:48:18 +01:00
parent e19ccb71c8
commit 7a03b4c75a

View File

@ -99,7 +99,10 @@ impl<'a> DiagnosticBuilder<'a> {
self.handler.emitter.borrow_mut().emit(&self); self.handler.emitter.borrow_mut().emit(&self);
self.cancel(); self.cancel();
self.handler.panic_if_treat_err_as_bug();
if self.level == Level::Error {
self.handler.panic_if_treat_err_as_bug();
}
// if self.is_fatal() { // if self.is_fatal() {
// panic!(FatalError); // panic!(FatalError);