diff options
| author | Brian Anderson <banderson@mozilla.com> | 2015-01-18 13:39:18 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2015-01-20 11:27:51 -0800 |
| commit | f68029ec94415298e56ab20f73bcf2a1224ace4d (patch) | |
| tree | 2f45d58f772cba8be3ef47d055b668a0f59ba8eb /src/libsyntax | |
| parent | 0c5225c5bf31dcca141c36ce1b5850ff2df79b9c (diff) | |
| download | rust-f68029ec94415298e56ab20f73bcf2a1224ace4d.tar.gz rust-f68029ec94415298e56ab20f73bcf2a1224ace4d.zip | |
Make fatal errors work with codes, add to typeck
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/diagnostic.rs | 4 | ||||
| -rw-r--r-- | src/libsyntax/diagnostics/macros.rs | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 7213b0fa955..b26ec64c24b 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -92,6 +92,10 @@ impl SpanHandler { self.handler.emit(Some((&self.cm, sp)), msg, Fatal); panic!(FatalError); } + pub fn span_fatal_with_code(&self, sp: Span, msg: &str, code: &str) -> ! { + self.handler.emit_with_code(Some((&self.cm, sp)), msg, code, Fatal); + panic!(FatalError); + } pub fn span_err(&self, sp: Span, msg: &str) { self.handler.emit(Some((&self.cm, sp)), msg, Error); self.handler.bump_err_count(); diff --git a/src/libsyntax/diagnostics/macros.rs b/src/libsyntax/diagnostics/macros.rs index 34a193dffd3..5bd683c86ae 100644 --- a/src/libsyntax/diagnostics/macros.rs +++ b/src/libsyntax/diagnostics/macros.rs @@ -15,6 +15,14 @@ macro_rules! register_diagnostic { } #[macro_export] +macro_rules! span_fatal { + ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({ + __diagnostic_used!($code); + $session.span_fatal_with_code($span, format!($($message)*).as_slice(), stringify!($code)) + }) +} + +#[macro_export] macro_rules! span_err { ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({ __diagnostic_used!($code); |
