]> git.lizzy.rs Git - rust.git/commitdiff
syntax: Suppress panic message on `fatal`
authorAlex Crichton <alex@alexcrichton.com>
Mon, 20 Jul 2015 16:23:31 +0000 (09:23 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 20 Jul 2015 16:23:31 +0000 (09:23 -0700)
This commit ensures that the rustc thread does not leak a panic message whenever
a call to `fatal` happens. This already happens for the main rustc thread as
part of the `rustc_driver::monitor` function, but the compiler also spawns
threads for other operations like `-C codegen-units`, and sometimes errors are
emitted on these threads as well. To ensure that there's a consistent
error-handling experience across threads this unifies these two to never print
the panic message in the case of a normal and expected fatal error.

This should also fix the flaky `asm-src-loc-codegen-units.rs` test as the output
is sometimes garbled if diagnostics are printed while the panic message is also
being printed.

src/libsyntax/diagnostic.rs
src/libsyntax/lib.rs

index fbf015169f858b8086be80939a6e60de2633b7bf..e95813e44babe0b6cb636d7925728019cbc26c3d 100644 (file)
@@ -208,6 +208,10 @@ pub fn with_emitter(can_emit_warnings: bool, e: Box<Emitter + Send>) -> Handler
     }
     pub fn fatal(&self, msg: &str) -> ! {
         self.emit.borrow_mut().emit(None, msg, None, Fatal);
+
+        // Suppress the fatal error message from the panic below as we've
+        // already terminated in our own "legitimate" fashion.
+        io::set_panic(Box::new(io::sink()));
         panic!(FatalError);
     }
     pub fn err(&self, msg: &str) {
index 7333265bdd41246bc0ea2afbe2385814d2e081a2..d93af5da13c1e2803a2aa263e9340d3df035a42b 100644 (file)
@@ -32,6 +32,7 @@
 #![feature(libc)]
 #![feature(ref_slice)]
 #![feature(rustc_private)]
+#![feature(set_stdio)]
 #![feature(staged_api)]
 #![feature(str_char)]
 #![feature(str_escape)]