about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorJakub Wieczorek <jakub@jakub.cc>2014-07-11 18:54:01 +0200
committerJakub Wieczorek <jakub@jakub.cc>2014-07-12 21:53:34 +0200
commita5fe176e9715f6e67a3ede3d204ba84b2f92ce7d (patch)
treed8df65f649f4df474a02e6baf9d4b371b802e5f5 /src/libsyntax
parent350f3aa856682fed816a0a2018b3bcf50178eeff (diff)
downloadrust-a5fe176e9715f6e67a3ede3d204ba84b2f92ce7d.tar.gz
rust-a5fe176e9715f6e67a3ede3d204ba84b2f92ce7d.zip
Convert a first batch of diagnostics to have error codes
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/diagnostic.rs3
-rw-r--r--src/libsyntax/diagnostics/macros.rs22
-rw-r--r--src/libsyntax/diagnostics/plugin.rs3
3 files changed, 27 insertions, 1 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs
index 9bb5eae2ed2..0b26a641f8d 100644
--- a/src/libsyntax/diagnostic.rs
+++ b/src/libsyntax/diagnostic.rs
@@ -98,6 +98,9 @@ impl SpanHandler {
     pub fn span_warn(&self, sp: Span, msg: &str) {
         self.handler.emit(Some((&self.cm, sp)), msg, Warning);
     }
+    pub fn span_warn_with_code(&self, sp: Span, msg: &str, code: &str) {
+        self.handler.emit_with_code(Some((&self.cm, sp)), msg, code, Warning);
+    }
     pub fn span_note(&self, sp: Span, msg: &str) {
         self.handler.emit(Some((&self.cm, sp)), msg, Note);
     }
diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs
index b0260e1180f..b4af7205c42 100644
--- a/src/libsyntax/diagnostics/macros.rs
+++ b/src/libsyntax/diagnostics/macros.rs
@@ -49,3 +49,25 @@ macro_rules! span_err(
         ($session).span_err_with_code($span, format!($($arg),*).as_slice(), stringify!($code))
     })
 )
+
+#[macro_export]
+macro_rules! span_warn(
+    ($session:expr, $span:expr, $code:ident, $($arg:expr),*) => ({
+        __diagnostic_used!($code);
+        ($session).span_warn_with_code($span, format!($($arg),*).as_slice(), stringify!($code))
+    })
+)
+
+#[macro_export]
+macro_rules! span_note(
+    ($session:expr, $span:expr, $($arg:expr),*) => ({
+        ($session).span_note($span, format!($($arg),*).as_slice())
+    })
+)
+
+#[macro_export]
+macro_rules! register_diagnostics(
+    ($($code:tt),*) => (
+        $(register_diagnostic!($code))*
+    )
+)
diff --git a/src/libsyntax/diagnostics/plugin.rs b/src/libsyntax/diagnostics/plugin.rs
index 6582d2e44c8..209296989fa 100644
--- a/src/libsyntax/diagnostics/plugin.rs
+++ b/src/libsyntax/diagnostics/plugin.rs
@@ -54,7 +54,8 @@ pub fn expand_diagnostic_used(ecx: &mut ExtCtxt, span: Span,
     with_registered_diagnostics(|diagnostics| {
         if !diagnostics.contains_key(&code.name) {
             ecx.span_err(span, format!(
-                "unknown diagnostic code {}", token::get_ident(code).get()
+                "unknown diagnostic code {}; add to librustc/diagnostics.rs",
+                token::get_ident(code).get()
             ).as_slice());
         }
         ()