]> git.lizzy.rs Git - rust.git/commitdiff
rustc_errors: fix a few bugs
authorAriel Ben-Yehuda <arielb1@mail.tau.ac.il>
Thu, 21 Jul 2016 17:12:04 +0000 (20:12 +0300)
committerAriel Ben-Yehuda <ariel.byd@gmail.com>
Fri, 22 Jul 2016 19:47:38 +0000 (22:47 +0300)
src/librustc_errors/lib.rs

index 6a48f65714cc50d95e6463d337ec64af32233dd1..610e5647d6d12893547923c65d361474d0914c00 100644 (file)
@@ -531,10 +531,12 @@ pub fn struct_fatal<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
         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();
     }