]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_errors/diagnostic_builder.rs
Rollup merge of #68515 - Wind-River:master_2020, r=alexcrichton
[rust.git] / src / librustc_errors / diagnostic_builder.rs
index ef3a4a9a7080d48978dbe98e6b434d69c6832c68..3c217c1d64373556cdd9605e89605d22d836cede 100644 (file)
@@ -2,10 +2,10 @@
 use crate::{Diagnostic, DiagnosticId, DiagnosticStyledString};
 
 use log::debug;
+use rustc_span::{MultiSpan, Span};
 use std::fmt::{self, Debug};
 use std::ops::{Deref, DerefMut};
 use std::thread::panicking;
-use syntax_pos::{MultiSpan, Span};
 
 /// Used for emitting structured error messages and other diagnostic information.
 ///
@@ -385,3 +385,19 @@ fn drop(&mut self) {
         }
     }
 }
+
+#[macro_export]
+macro_rules! struct_span_err {
+    ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
+        $session.struct_span_err_with_code(
+            $span,
+            &format!($($message)*),
+            $crate::error_code!($code),
+        )
+    })
+}
+
+#[macro_export]
+macro_rules! error_code {
+    ($code:ident) => {{ $crate::DiagnosticId::Error(stringify!($code).to_owned()) }};
+}