about summary refs log tree commit diff
path: root/src/librustc_errors/diagnostic_builder.rs
diff options
context:
space:
mode:
authorRafael Fernández López <ereslibre@ereslibre.es>2018-01-02 20:00:12 +0100
committerRafael Fernández López <ereslibre@ereslibre.es>2018-01-03 00:42:12 +0100
commit063607eecbbdff53ee0cbc4b3f9a8ff49448f741 (patch)
treeb9afbec5a28b4b2165f8895e7211ed369ae84d9e /src/librustc_errors/diagnostic_builder.rs
parent687d3d15ba726dbb1ac6b85223ebe0e98c6820cc (diff)
downloadrust-063607eecbbdff53ee0cbc4b3f9a8ff49448f741.tar.gz
rust-063607eecbbdff53ee0cbc4b3f9a8ff49448f741.zip
Only bump error count when we are sure that the diagnostic is not a repetition.
This ensures that if we emit the same diagnostic twice, the error count will
match the real number of errors shown to the user.

Fixes #42106
Diffstat (limited to 'src/librustc_errors/diagnostic_builder.rs')
-rw-r--r--src/librustc_errors/diagnostic_builder.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs
index 27e895164e7..61674ada6fa 100644
--- a/src/librustc_errors/diagnostic_builder.rs
+++ b/src/librustc_errors/diagnostic_builder.rs
@@ -83,7 +83,12 @@ impl<'a> DiagnosticBuilder<'a> {
             return;
         }
 
-        let is_error = match self.level {
+        self.handler.emit_db(&self);
+        self.cancel();
+    }
+
+    pub fn is_error(&self) -> bool {
+        match self.level {
             Level::Bug |
             Level::Fatal |
             Level::PhaseFatal |
@@ -97,18 +102,7 @@ impl<'a> DiagnosticBuilder<'a> {
             Level::Cancelled => {
                 false
             }
-        };
-
-        self.handler.emit_db(&self);
-        self.cancel();
-
-        if is_error {
-            self.handler.bump_err_count();
         }
-
-        // if self.is_fatal() {
-        //     panic!(FatalError);
-        // }
     }
 
     /// Convenience function for internal use, clients should use one of the