]> git.lizzy.rs Git - rust.git/commitdiff
Simplify panic_if_treat_err_as_bug avoiding allocations
authorJuan Aguilar Santillana <mhpoin@gmail.com>
Fri, 18 Sep 2020 05:57:01 +0000 (05:57 +0000)
committerJuan Aguilar Santillana <mhpoin@gmail.com>
Fri, 18 Sep 2020 05:57:01 +0000 (05:57 +0000)
compiler/rustc_errors/src/lib.rs

index 2abd20869aecf0e66341ada087654164f1973c32..b16fe5603c1001f74868b926bf126f99f0d83075 100644 (file)
@@ -973,16 +973,14 @@ fn bump_warn_count(&mut self) {
 
     fn panic_if_treat_err_as_bug(&self) {
         if self.treat_err_as_bug() {
-            let s = match (self.err_count(), self.flags.treat_err_as_bug.unwrap_or(0)) {
-                (0, _) => return,
-                (1, 1) => "aborting due to `-Z treat-err-as-bug=1`".to_string(),
-                (1, _) => return,
-                (count, as_bug) => format!(
+            match (self.err_count(), self.flags.treat_err_as_bug.unwrap_or(0)) {
+                (1, 1) => panic!("aborting due to `-Z treat-err-as-bug=1`"),
+                (0, _) | (1, _) => {}
+                (count, as_bug) => panic!(
                     "aborting after {} errors due to `-Z treat-err-as-bug={}`",
                     count, as_bug,
                 ),
-            };
-            panic!(s);
+            }
         }
     }
 }