Skip to content

Commit

Permalink
syntax: Suppress panic message on fatal
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
alexcrichton committed Jul 20, 2015
1 parent b5dad7d commit 013d47b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libsyntax/diagnostic.rs
Expand Up @@ -208,6 +208,10 @@ impl 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) {
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Expand Up @@ -32,6 +32,7 @@
#![feature(libc)]
#![feature(ref_slice)]
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(str_char)]
#![feature(str_escape)]
Expand Down

0 comments on commit 013d47b

Please sign in to comment.