about summary refs log tree commit diff
path: root/compiler/rustc_errors/src
diff options
context:
space:
mode:
authorJuan Aguilar Santillana <mhpoin@gmail.com>2020-09-18 05:57:01 +0000
committerJuan Aguilar Santillana <mhpoin@gmail.com>2020-09-18 05:57:01 +0000
commit28cfa9730eec41314dee99323f7d20aaadde9e0e (patch)
tree0940b7f7a87e7c3c0903cd32ae0b9ac33899b2f6 /compiler/rustc_errors/src
parent7b5d9836c47509e16900a274ed0b552a2e30a36a (diff)
downloadrust-28cfa9730eec41314dee99323f7d20aaadde9e0e.tar.gz
rust-28cfa9730eec41314dee99323f7d20aaadde9e0e.zip
Simplify panic_if_treat_err_as_bug avoiding allocations
Diffstat (limited to 'compiler/rustc_errors/src')
-rw-r--r--compiler/rustc_errors/src/lib.rs12
1 files changed, 5 insertions, 7 deletions
diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs
index 2abd20869ae..b16fe5603c1 100644
--- a/compiler/rustc_errors/src/lib.rs
+++ b/compiler/rustc_errors/src/lib.rs
@@ -973,16 +973,14 @@ impl HandlerInner {
 
     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);
+            }
         }
     }
 }