Skip to content

Commit 247a0d1

Browse files
committed
Auto merge of #27153 - alexcrichton:flaky-tests, r=brson
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.
2 parents 691ce23 + 013d47b commit 247a0d1

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/libsyntax/diagnostic.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ impl Handler {
208208
}
209209
pub fn fatal(&self, msg: &str) -> ! {
210210
self.emit.borrow_mut().emit(None, msg, None, Fatal);
211+
212+
// Suppress the fatal error message from the panic below as we've
213+
// already terminated in our own "legitimate" fashion.
214+
io::set_panic(Box::new(io::sink()));
211215
panic!(FatalError);
212216
}
213217
pub fn err(&self, msg: &str) {

src/libsyntax/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#![feature(libc)]
3333
#![feature(ref_slice)]
3434
#![feature(rustc_private)]
35+
#![feature(set_stdio)]
3536
#![feature(staged_api)]
3637
#![feature(str_char)]
3738
#![feature(str_escape)]

0 commit comments

Comments
 (0)