diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-01-21 12:47:58 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-01-26 04:52:30 +0100 |
| commit | 9a8d6b8bb5dd7dd2d378849f0c2fa586e3a5b48b (patch) | |
| tree | ee04624362f08eb705597831fbc197b68c8d20a7 /src/librustc_errors | |
| parent | 9fd7da904b46ff7aa78c2e2cc1986c4975aeccc6 (diff) | |
| download | rust-9a8d6b8bb5dd7dd2d378849f0c2fa586e3a5b48b.tar.gz rust-9a8d6b8bb5dd7dd2d378849f0c2fa586e3a5b48b.zip | |
Do not capture stderr in the compiler. Instead just panic silently for fatal errors
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/lib.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 1fb673815ee..33948ea92b9 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -19,6 +19,7 @@ #![cfg_attr(unix, feature(libc))] #![feature(conservative_impl_trait)] #![feature(i128_type)] +#![feature(optin_builtin_traits)] extern crate term; #[cfg(unix)] @@ -44,6 +45,7 @@ use std::rc::Rc; use std::{error, fmt}; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering::SeqCst; +use std::panic; mod diagnostic; mod diagnostic_builder; @@ -201,6 +203,18 @@ impl CodeSuggestion { #[must_use] pub struct FatalError; +pub struct FatalErrorMarker; + +// Don't implement Send on FatalError. This makes it impossible to panic!(FatalError). +// We don't want to invoke the panic handler and print a backtrace for fatal errors. +impl !Send for FatalError {} + +impl FatalError { + pub fn raise(self) -> ! { + panic::resume_unwind(Box::new(FatalErrorMarker)) + } +} + impl fmt::Display for FatalError { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { write!(f, "parser fatal error") @@ -539,7 +553,7 @@ impl Handler { } } - panic!(self.fatal(&s)); + self.fatal(&s).raise(); } pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) { if lvl == Warning && !self.flags.can_emit_warnings { |
