about summary refs log tree commit diff
path: root/src/librustc_errors
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2018-03-25 01:26:24 +0800
committerGitHub <noreply@github.com>2018-03-25 01:26:24 +0800
commit9c5f372a9aae3de4812ee5d3d092c46e7f1509b9 (patch)
tree45ecb647c55318eb4a70dc12da817527edb23c06 /src/librustc_errors
parentb4aa80dd73df9708022cc383aad8da1dcf38d1df (diff)
parentb1d872b38eaacefbef73faa6a4a0c07622a8c941 (diff)
downloadrust-9c5f372a9aae3de4812ee5d3d092c46e7f1509b9.tar.gz
rust-9c5f372a9aae3de4812ee5d3d092c46e7f1509b9.zip
Rollup merge of #49046 - Zoxc:error-summary, r=michaelwoerister
Always print `aborting due to n previous error(s)`

r? @michaelwoerister
Diffstat (limited to 'src/librustc_errors')
-rw-r--r--src/librustc_errors/lib.rs34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs
index a25c3668bb1..dcbea793ba6 100644
--- a/src/librustc_errors/lib.rs
+++ b/src/librustc_errors/lib.rs
@@ -558,21 +558,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();
@@ -603,8 +597,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 {