about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/diagnostic_builder.rs12
-rw-r--r--src/librustc_errors/lib.rs5
2 files changed, 7 insertions, 10 deletions
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs
index 6f6470089d7..5d7c5e2829a 100644
--- a/src/librustc_errors/diagnostic_builder.rs
+++ b/src/librustc_errors/diagnostic_builder.rs
@@ -82,26 +82,27 @@ impl<'a> DiagnosticBuilder<'a> {
             return;
         }
 
-        match self.level {
+        let is_error = match self.level {
             Level::Bug |
             Level::Fatal |
             Level::PhaseFatal |
             Level::Error => {
-                self.handler.bump_err_count();
+                true
             }
 
             Level::Warning |
             Level::Note |
             Level::Help |
             Level::Cancelled => {
+                false
             }
-        }
+        };
 
         self.handler.emitter.borrow_mut().emit(&self);
         self.cancel();
 
-        if self.level == Level::Error {
-            self.handler.panic_if_treat_err_as_bug();
+        if is_error {
+            self.handler.bump_err_count();
         }
 
         // if self.is_fatal() {
@@ -210,4 +211,3 @@ impl<'a> Drop for DiagnosticBuilder<'a> {
         }
     }
 }
-
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index e873137444d..159d2c7a2df 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -399,7 +399,6 @@ impl Handler {
 
     pub fn span_fatal<S: Into<MultiSpan>>(&self, sp: S, msg: &str) -> FatalError {
         self.emit(&sp.into(), msg, Fatal);
-        self.panic_if_treat_err_as_bug();
         FatalError
     }
     pub fn span_fatal_with_code<S: Into<MultiSpan>>(&self,
@@ -408,12 +407,10 @@ impl Handler {
                                                     code: &str)
                                                     -> FatalError {
         self.emit_with_code(&sp.into(), msg, code, Fatal);
-        self.panic_if_treat_err_as_bug();
         FatalError
     }
     pub fn span_err<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
         self.emit(&sp.into(), msg, Error);
-        self.panic_if_treat_err_as_bug();
     }
     pub fn mut_span_err<'a, S: Into<MultiSpan>>(&'a self,
                                                 sp: S,
@@ -425,7 +422,6 @@ impl Handler {
     }
     pub fn span_err_with_code<S: Into<MultiSpan>>(&self, sp: S, msg: &str, code: &str) {
         self.emit_with_code(&sp.into(), msg, code, Error);
-        self.panic_if_treat_err_as_bug();
     }
     pub fn span_warn<S: Into<MultiSpan>>(&self, sp: S, msg: &str) {
         self.emit(&sp.into(), msg, Warning);
@@ -494,6 +490,7 @@ impl Handler {
     }
 
     pub fn bump_err_count(&self) {
+        self.panic_if_treat_err_as_bug();
         self.err_count.set(self.err_count.get() + 1);
     }