about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-10-27 08:21:22 +0200
committerOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>2017-11-02 10:19:41 +0100
commit6ae440e04806ef2a9d21df4ee6f9e0006db5b05f (patch)
tree9e32f9822b288a844c88833d0e1b1d8294def353 /src/libsyntax
parent88fb4c4fdad1b97c3499a26e24dcbc60c6853a80 (diff)
downloadrust-6ae440e04806ef2a9d21df4ee6f9e0006db5b05f.tar.gz
rust-6ae440e04806ef2a9d21df4ee6f9e0006db5b05f.zip
Make the difference between lint codes and error codes explicit
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostics/macros.rs65
-rw-r--r--src/libsyntax/json.rs8
2 files changed, 60 insertions, 13 deletions
diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs
index e8ecf58072a..c01836b6194 100644
--- a/src/libsyntax/diagnostics/macros.rs
+++ b/src/libsyntax/diagnostics/macros.rs
@@ -18,7 +18,11 @@ macro_rules! register_diagnostic {
 macro_rules! span_fatal {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.span_fatal_with_code($span, &format!($($message)*), stringify!($code))
+        $session.span_fatal_with_code(
+            $span,
+            &format!($($message)*),
+            $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+        )
     })
 }
 
@@ -26,7 +30,11 @@ macro_rules! span_fatal {
 macro_rules! span_err {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.span_err_with_code($span, &format!($($message)*), stringify!($code))
+        $session.span_err_with_code(
+            $span,
+            &format!($($message)*),
+            $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+        )
     })
 }
 
@@ -34,7 +42,11 @@ macro_rules! span_err {
 macro_rules! span_warn {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.span_warn_with_code($span, &format!($($message)*), stringify!($code))
+        $session.span_warn_with_code(
+            $span,
+            &format!($($message)*),
+            $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+        )
     })
 }
 
@@ -42,7 +54,10 @@ macro_rules! span_warn {
 macro_rules! struct_err {
     ($session:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.struct_err_with_code(&format!($($message)*), stringify!($code))
+        $session.struct_err_with_code(
+            &format!($($message)*),
+            $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+        )
     })
 }
 
@@ -51,9 +66,17 @@ macro_rules! span_err_or_warn {
     ($is_warning:expr, $session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
         if $is_warning {
-            $session.span_warn_with_code($span, &format!($($message)*), stringify!($code))
+            $session.span_warn_with_code(
+                $span,
+                &format!($($message)*),
+                $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+            )
         } else {
-            $session.span_err_with_code($span, &format!($($message)*), stringify!($code))
+            $session.span_err_with_code(
+                $span,
+                &format!($($message)*),
+                $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+            )
         }
     })
 }
@@ -62,7 +85,11 @@ macro_rules! span_err_or_warn {
 macro_rules! struct_span_fatal {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.struct_span_fatal_with_code($span, &format!($($message)*), stringify!($code))
+        $session.struct_span_fatal_with_code(
+            $span,
+            &format!($($message)*),
+            $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+        )
     })
 }
 
@@ -70,7 +97,11 @@ macro_rules! struct_span_fatal {
 macro_rules! struct_span_err {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.struct_span_err_with_code($span, &format!($($message)*), stringify!($code))
+        $session.struct_span_err_with_code(
+            $span,
+            &format!($($message)*),
+            $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+        )
     })
 }
 
@@ -89,7 +120,11 @@ macro_rules! type_error_struct {
 macro_rules! struct_span_warn {
     ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
-        $session.struct_span_warn_with_code($span, &format!($($message)*), stringify!($code))
+        $session.struct_span_warn_with_code(
+            $span,
+            &format!($($message)*),
+            $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+        )
     })
 }
 
@@ -98,9 +133,17 @@ macro_rules! struct_span_err_or_warn {
     ($is_warning:expr, $session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
         __diagnostic_used!($code);
         if $is_warning {
-            $session.struct_span_warn_with_code($span, &format!($($message)*), stringify!($code))
+            $session.struct_span_warn_with_code(
+                $span,
+                &format!($($message)*),
+                $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+            )
         } else {
-            $session.struct_span_err_with_code($span, &format!($($message)*), stringify!($code))
+            $session.struct_span_err_with_code(
+                $span,
+                &format!($($message)*),
+                $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
+            )
         }
     })
 }
diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs
index b8151819bff..31fe0c234e8 100644
--- a/src/libsyntax/json.rs
+++ b/src/libsyntax/json.rs
@@ -23,6 +23,7 @@ use codemap::{CodeMap, FilePathMapping};
 use syntax_pos::{self, MacroBacktrace, Span, SpanLabel, MultiSpan};
 use errors::registry::Registry;
 use errors::{DiagnosticBuilder, SubDiagnostic, RenderSpan, CodeSuggestion, CodeMapper};
+use errors::DiagnosticId;
 use errors::emitter::Emitter;
 
 use std::rc::Rc;
@@ -340,9 +341,12 @@ impl DiagnosticSpanLine {
 }
 
 impl DiagnosticCode {
-    fn map_opt_string(s: Option<String>, je: &JsonEmitter) -> Option<DiagnosticCode> {
+    fn map_opt_string(s: Option<DiagnosticId>, je: &JsonEmitter) -> Option<DiagnosticCode> {
         s.map(|s| {
-
+            let s = match s {
+                DiagnosticId::Error(s) => s,
+                DiagnosticId::Lint(s) => s,
+            };
             let explanation = je.registry
                                 .as_ref()
                                 .and_then(|registry| registry.find_description(&s));