diff options
| author | Eli Friedman <eli.friedman@gmail.com> | 2015-10-23 19:42:42 -0700 |
|---|---|---|
| committer | Eli Friedman <eli.friedman@gmail.com> | 2015-10-27 20:09:10 -0700 |
| commit | e5024924ad6d7403c8ab73798b30ff501a10a391 (patch) | |
| tree | 6d9823f034c96f1438e1c43e7997cdfd65e0cc39 /src/libsyntax | |
| parent | 329e487e582cba7ae1eaa444b0d004cee94ae7c3 (diff) | |
| download | rust-e5024924ad6d7403c8ab73798b30ff501a10a391.tar.gz rust-e5024924ad6d7403c8ab73798b30ff501a10a391.zip | |
Make fatal errors more consistent.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 23 | ||||
| -rw-r--r-- | src/libsyntax/lib.rs | 1 | ||||
| -rw-r--r-- | src/libsyntax/parse/mod.rs | 2 |
3 files changed, 11 insertions, 15 deletions
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<Span>) 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)) } } } |
