]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_errors/lib.rs
Add new error code
[rust.git] / src / librustc_errors / lib.rs
index c91dc9d87978dedb3c1011792010971c70ab0e29..d1aaaf4ba7b378c7e8dd0f2f9e78cf5b15a525b8 100644 (file)
@@ -345,9 +345,15 @@ pub fn struct_span_err_with_code<'a, S: Into<MultiSpan>>(&'a self,
         result.code(code.to_owned());
         result
     }
+    // FIXME: This method should be removed (every error should have an associated error code).
     pub fn struct_err<'a>(&'a self, msg: &str) -> DiagnosticBuilder<'a> {
         DiagnosticBuilder::new(self, Level::Error, msg)
     }
+    pub fn struct_err_with_code<'a>(&'a self, msg: &str, code: &str) -> DiagnosticBuilder<'a> {
+        let mut result = DiagnosticBuilder::new(self, Level::Error, msg);
+        result.code(code.to_owned());
+        result
+    }
     pub fn struct_span_fatal<'a, S: Into<MultiSpan>>(&'a self,
                                                      sp: S,
                                                      msg: &str)
@@ -501,10 +507,7 @@ pub fn abort_if_errors(&self) {
 
                 return;
             }
-            1 => s = "aborting due to previous error".to_string(),
-            _ => {
-                s = format!("aborting due to {} previous errors", self.err_count.get());
-            }
+            _ => s = "aborting due to previous error(s)".to_string(),
         }
 
         panic!(self.fatal(&s));