diff options
| author | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-03-15 10:09:20 +0100 |
|---|---|---|
| committer | John Kåre Alsaker <john.kare.alsaker@gmail.com> | 2018-03-16 11:25:37 +0100 |
| commit | 910bf840cce1da57b96f7ac15f8b803675bb8a3b (patch) | |
| tree | 8585aa1f7dc9e0687702611e02a149d5b6b98f33 /src/librustc_errors | |
| parent | 3b43dcbb4c62a36b68afd7f9a1bf12aed1b53d7d (diff) | |
| download | rust-910bf840cce1da57b96f7ac15f8b803675bb8a3b.tar.gz rust-910bf840cce1da57b96f7ac15f8b803675bb8a3b.zip | |
Always print `aborting due to n previous error(s)` and only print it once for multi-threaded code
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/lib.rs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 7148969191f..b3265c21884 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -555,21 +555,15 @@ impl Handler { pub fn has_errors(&self) -> bool { self.err_count() > 0 } - pub fn abort_if_errors(&self) { - let s; - match self.err_count() { - 0 => { - if let Some(bug) = self.delayed_span_bug.borrow_mut().take() { - DiagnosticBuilder::new_diagnostic(self, bug).emit(); - } - return; - } - 1 => s = "aborting due to previous error".to_string(), - _ => { - s = format!("aborting due to {} previous errors", self.err_count()); - } - } - let err = self.fatal(&s); + + pub fn print_error_count(&self) { + let s = match self.err_count() { + 0 => return, + 1 => "aborting due to previous error".to_string(), + _ => format!("aborting due to {} previous errors", self.err_count()) + }; + + let _ = self.fatal(&s); let can_show_explain = self.emitter.borrow().should_show_explain(); let are_there_diagnostics = !self.tracked_diagnostic_codes.borrow().is_empty(); @@ -600,8 +594,16 @@ impl Handler { } } } + } - err.raise(); + pub fn abort_if_errors(&self) { + if self.err_count() == 0 { + if let Some(bug) = self.delayed_span_bug.borrow_mut().take() { + DiagnosticBuilder::new_diagnostic(self, bug).emit(); + } + return; + } + FatalError.raise(); } pub fn emit(&self, msp: &MultiSpan, msg: &str, lvl: Level) { if lvl == Warning && !self.flags.can_emit_warnings { |
