From e5024924ad6d7403c8ab73798b30ff501a10a391 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Fri, 23 Oct 2015 19:42:42 -0700 Subject: Make fatal errors more consistent. --- src/libsyntax/diagnostic.rs | 23 ++++++++++------------- src/libsyntax/lib.rs | 1 - src/libsyntax/parse/mod.rs | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'src/libsyntax') diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 2a8cdf138b0..2b34db3f6ea 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -206,13 +206,9 @@ impl Handler { can_emit_warnings: can_emit_warnings } } - pub fn fatal(&self, msg: &str) -> ! { + pub fn fatal(&self, msg: &str) -> FatalError { 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); + FatalError } pub fn err(&self, msg: &str) { self.emit.borrow_mut().emit(None, msg, None, Error); @@ -230,14 +226,15 @@ impl Handler { pub fn abort_if_errors(&self) { let s; match self.err_count.get() { - 0 => return, - 1 => s = "aborting due to previous error".to_string(), - _ => { - s = format!("aborting due to {} previous errors", - self.err_count.get()); - } + 0 => return, + 1 => s = "aborting due to previous error".to_string(), + _ => { + s = format!("aborting due to {} previous errors", + self.err_count.get()); + } } - self.fatal(&s[..]); + + panic!(self.fatal(&s[..])); } pub fn warn(&self, msg: &str) { self.emit.borrow_mut().emit(None, msg, None, Warning); diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 406b763ca46..8b001f2419c 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -30,7 +30,6 @@ #![feature(filling_drop)] #![feature(libc)] #![feature(rustc_private)] -#![feature(set_stdio)] #![feature(staged_api)] #![feature(str_char)] #![feature(str_escape)] diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index bbecedf92ea..15625cba65c 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -235,7 +235,7 @@ fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option) let msg = format!("couldn't read {:?}: {}", path.display(), e); match spanopt { Some(sp) => panic!(sess.span_diagnostic.span_fatal(sp, &msg)), - None => sess.span_diagnostic.handler().fatal(&msg) + None => panic!(sess.span_diagnostic.handler().fatal(&msg)) } } } -- cgit 1.4.1-3-g733a5