about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>2016-07-21 20:12:04 +0300
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2016-07-22 22:47:38 +0300
commit1e4f6d56836e9f9867bb8b05efc2fffceab6b423 (patch)
tree68fc50d8165f59527070649043736eb2eeb5b1b9 /src/librustc_errors
parentf3ee99bd4d9d282c33127449073c521f29b07c21 (diff)
downloadrust-1e4f6d56836e9f9867bb8b05efc2fffceab6b423.tar.gz
rust-1e4f6d56836e9f9867bb8b05efc2fffceab6b423.zip
rustc_errors: fix a few bugs
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index 6a48f65714c..610e5647d6d 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -531,10 +531,12 @@ impl Handler {
         DiagnosticBuilder::new(self, Level::Fatal, msg)
     }
 
-    pub fn cancel(&mut self, err: &mut DiagnosticBuilder) {
+    pub fn cancel(&self, err: &mut DiagnosticBuilder) {
         if err.level == Level::Error || err.level == Level::Fatal {
-            assert!(self.has_errors());
-            self.err_count.set(self.err_count.get() + 1);
+            self.err_count.set(
+                self.err_count.get().checked_sub(1)
+                    .expect("cancelled an error but err_count is 0")
+            );
         }
         err.cancel();
     }