Skip to content

Commit 4d52b0f

Browse files
committed
Utilize if..let over single match branch.
1 parent 77eb78a commit 4d52b0f

File tree

1 file changed

+28
-33
lines changed

1 file changed

+28
-33
lines changed

src/librustc_driver/lib.rs

+28-33
Original file line numberDiff line numberDiff line change
@@ -1033,43 +1033,38 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
10331033
cfg = cfg.stack_size(STACK_SIZE);
10341034
}
10351035

1036-
match cfg.spawn(move || {
1037-
io::set_panic(box err);
1038-
f()
1039-
})
1040-
.unwrap()
1041-
.join() {
1042-
Ok(()) => {
1043-
// fallthrough
1044-
}
1045-
Err(value) => {
1046-
// Thread panicked without emitting a fatal diagnostic
1047-
if !value.is::<errors::FatalError>() {
1048-
let mut emitter = errors::emitter::BasicEmitter::stderr(errors::ColorConfig::Auto);
1049-
1050-
// a .span_bug or .bug call has already printed what
1051-
// it wants to print.
1052-
if !value.is::<errors::ExplicitBug>() {
1053-
emitter.emit(None, "unexpected panic", None, errors::Level::Bug);
1054-
}
1055-
1056-
let xs = ["the compiler unexpectedly panicked. this is a bug.".to_string(),
1057-
format!("we would appreciate a bug report: {}", BUG_REPORT_URL)];
1058-
for note in &xs {
1059-
emitter.emit(None, &note[..], None, errors::Level::Note)
1060-
}
1061-
if let None = env::var_os("RUST_BACKTRACE") {
1062-
emitter.emit(None,
1063-
"run with `RUST_BACKTRACE=1` for a backtrace",
1064-
None,
1065-
errors::Level::Note);
1066-
}
1036+
let thread = cfg.spawn(move || {
1037+
io::set_panic(box err);
1038+
f()
1039+
});
1040+
1041+
if let Err(value) = thread.unwrap().join() {
1042+
// Thread panicked without emitting a fatal diagnostic
1043+
if !value.is::<errors::FatalError>() {
1044+
let mut emitter = errors::emitter::BasicEmitter::stderr(errors::ColorConfig::Auto);
1045+
1046+
// a .span_bug or .bug call has already printed what
1047+
// it wants to print.
1048+
if !value.is::<errors::ExplicitBug>() {
1049+
emitter.emit(None, "unexpected panic", None, errors::Level::Bug);
1050+
}
10671051

1068-
println!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
1052+
let xs = ["the compiler unexpectedly panicked. this is a bug.".to_string(),
1053+
format!("we would appreciate a bug report: {}", BUG_REPORT_URL)];
1054+
for note in &xs {
1055+
emitter.emit(None, &note[..], None, errors::Level::Note)
1056+
}
1057+
if let None = env::var_os("RUST_BACKTRACE") {
1058+
emitter.emit(None,
1059+
"run with `RUST_BACKTRACE=1` for a backtrace",
1060+
None,
1061+
errors::Level::Note);
10691062
}
10701063

1071-
exit_on_err();
1064+
println!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
10721065
}
1066+
1067+
exit_on_err();
10731068
}
10741069
}
10751070

0 commit comments

Comments
 (0)