about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-03-20 00:46:50 -0400
committerCorey Farwell <coreyf@rwell.org>2016-03-20 11:01:23 -0400
commit4d52b0f5507f9c1f86035fa1bbee2b53dcaa08b6 (patch)
tree000d8aa0c82016139a95b57f8037de3a091cd5a7
parent77eb78a8c583e17f0cf98a433eb42aa0fc63ce4f (diff)
downloadrust-4d52b0f5507f9c1f86035fa1bbee2b53dcaa08b6.tar.gz
rust-4d52b0f5507f9c1f86035fa1bbee2b53dcaa08b6.zip
Utilize `if..let` over single `match` branch.
-rw-r--r--src/librustc_driver/lib.rs61
1 files changed, 28 insertions, 33 deletions
diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs
index dc048807bcc..0fb192bb4db 100644
--- a/src/librustc_driver/lib.rs
+++ b/src/librustc_driver/lib.rs
@@ -1033,43 +1033,38 @@ pub fn monitor<F: FnOnce() + Send + 'static>(f: F) {
         cfg = cfg.stack_size(STACK_SIZE);
     }
 
-    match cfg.spawn(move || {
-                 io::set_panic(box err);
-                 f()
-             })
-             .unwrap()
-             .join() {
-        Ok(()) => {
-            // fallthrough
-        }
-        Err(value) => {
-            // Thread panicked without emitting a fatal diagnostic
-            if !value.is::<errors::FatalError>() {
-                let mut emitter = errors::emitter::BasicEmitter::stderr(errors::ColorConfig::Auto);
-
-                // a .span_bug or .bug call has already printed what
-                // it wants to print.
-                if !value.is::<errors::ExplicitBug>() {
-                    emitter.emit(None, "unexpected panic", None, errors::Level::Bug);
-                }
-
-                let xs = ["the compiler unexpectedly panicked. this is a bug.".to_string(),
-                          format!("we would appreciate a bug report: {}", BUG_REPORT_URL)];
-                for note in &xs {
-                    emitter.emit(None, &note[..], None, errors::Level::Note)
-                }
-                if let None = env::var_os("RUST_BACKTRACE") {
-                    emitter.emit(None,
-                                 "run with `RUST_BACKTRACE=1` for a backtrace",
-                                 None,
-                                 errors::Level::Note);
-                }
+    let thread = cfg.spawn(move || {
+         io::set_panic(box err);
+         f()
+     });
+
+     if let Err(value) = thread.unwrap().join() {
+        // Thread panicked without emitting a fatal diagnostic
+        if !value.is::<errors::FatalError>() {
+            let mut emitter = errors::emitter::BasicEmitter::stderr(errors::ColorConfig::Auto);
+
+            // a .span_bug or .bug call has already printed what
+            // it wants to print.
+            if !value.is::<errors::ExplicitBug>() {
+                emitter.emit(None, "unexpected panic", None, errors::Level::Bug);
+            }
 
-                println!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
+            let xs = ["the compiler unexpectedly panicked. this is a bug.".to_string(),
+                      format!("we would appreciate a bug report: {}", BUG_REPORT_URL)];
+            for note in &xs {
+                emitter.emit(None, &note[..], None, errors::Level::Note)
+            }
+            if let None = env::var_os("RUST_BACKTRACE") {
+                emitter.emit(None,
+                             "run with `RUST_BACKTRACE=1` for a backtrace",
+                             None,
+                             errors::Level::Note);
             }
 
-            exit_on_err();
+            println!("{}", str::from_utf8(&data.lock().unwrap()).unwrap());
         }
+
+        exit_on_err();
     }
 }