Skip to content

Commit

Permalink
Simplify panic_if_treat_err_as_bug avoiding allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
zzau13 committed Sep 18, 2020
1 parent 7b5d983 commit 28cfa97
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit 28cfa97

Please sign in to comment.