Skip to content

Commit 28cfa97

Browse files
committed
Simplify panic_if_treat_err_as_bug avoiding allocations
1 parent 7b5d983 commit 28cfa97

File tree

1 file changed

+5
-7
lines changed
  • compiler/rustc_errors/src

1 file changed

+5
-7
lines changed

compiler/rustc_errors/src/lib.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -973,16 +973,14 @@ impl HandlerInner {
973973

974974
fn panic_if_treat_err_as_bug(&self) {
975975
if self.treat_err_as_bug() {
976-
let s = match (self.err_count(), self.flags.treat_err_as_bug.unwrap_or(0)) {
977-
(0, _) => return,
978-
(1, 1) => "aborting due to `-Z treat-err-as-bug=1`".to_string(),
979-
(1, _) => return,
980-
(count, as_bug) => format!(
976+
match (self.err_count(), self.flags.treat_err_as_bug.unwrap_or(0)) {
977+
(1, 1) => panic!("aborting due to `-Z treat-err-as-bug=1`"),
978+
(0, _) | (1, _) => {}
979+
(count, as_bug) => panic!(
981980
"aborting after {} errors due to `-Z treat-err-as-bug={}`",
982981
count, as_bug,
983982
),
984-
};
985-
panic!(s);
983+
}
986984
}
987985
}
988986
}

0 commit comments

Comments
 (0)