2014-07-01 11:39:41 -05:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
#[macro_export]
|
2014-11-14 11:18:10 -06:00
|
|
|
macro_rules! register_diagnostic {
|
|
|
|
($code:tt, $description:tt) => (__register_diagnostic! { $code, $description });
|
|
|
|
($code:tt) => (__register_diagnostic! { $code })
|
|
|
|
}
|
2014-07-01 11:39:41 -05:00
|
|
|
|
2015-01-18 15:39:18 -06:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! span_fatal {
|
|
|
|
($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
|
|
|
|
__diagnostic_used!($code);
|
2015-02-01 20:53:25 -06:00
|
|
|
$session.span_fatal_with_code($span, &format!($($message)*), stringify!($code))
|
2015-01-18 15:39:18 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-01 11:39:41 -05:00
|
|
|
#[macro_export]
|
2014-11-14 11:18:10 -06:00
|
|
|
macro_rules! span_err {
|
2014-07-17 12:56:37 -05:00
|
|
|
($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
|
2014-07-01 11:39:41 -05:00
|
|
|
__diagnostic_used!($code);
|
2015-02-01 20:53:25 -06:00
|
|
|
$session.span_err_with_code($span, &format!($($message)*), stringify!($code))
|
2014-07-01 11:39:41 -05:00
|
|
|
})
|
2014-11-14 11:18:10 -06:00
|
|
|
}
|
2014-07-11 11:54:01 -05:00
|
|
|
|
2015-12-20 15:00:43 -06:00
|
|
|
#[macro_export]
|
|
|
|
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))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2015-08-07 09:28:51 -05:00
|
|
|
#[macro_export]
|
|
|
|
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))
|
|
|
|
} else {
|
|
|
|
$session.span_err_with_code($span, &format!($($message)*), stringify!($code))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-11 11:54:01 -05:00
|
|
|
#[macro_export]
|
2015-12-20 15:00:43 -06:00
|
|
|
macro_rules! struct_span_fatal {
|
2014-07-17 12:56:37 -05:00
|
|
|
($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
|
2014-07-11 11:54:01 -05:00
|
|
|
__diagnostic_used!($code);
|
2015-12-20 15:00:43 -06:00
|
|
|
$session.struct_span_fatal_with_code($span, &format!($($message)*), stringify!($code))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
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))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
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))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
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))
|
|
|
|
} else {
|
|
|
|
$session.struct_span_err_with_code($span, &format!($($message)*), stringify!($code))
|
|
|
|
}
|
2014-07-11 11:54:01 -05:00
|
|
|
})
|
2014-11-14 11:18:10 -06:00
|
|
|
}
|
2014-07-11 11:54:01 -05:00
|
|
|
|
|
|
|
#[macro_export]
|
2014-11-14 11:18:10 -06:00
|
|
|
macro_rules! span_note {
|
2015-12-20 15:00:43 -06:00
|
|
|
($err:expr, $span:expr, $($message:tt)*) => ({
|
|
|
|
($err).span_note($span, &format!($($message)*));
|
2014-07-11 11:54:01 -05:00
|
|
|
})
|
2014-11-14 11:18:10 -06:00
|
|
|
}
|
2014-07-11 11:54:01 -05:00
|
|
|
|
2014-10-28 18:59:36 -05:00
|
|
|
#[macro_export]
|
2014-11-14 11:18:10 -06:00
|
|
|
macro_rules! span_help {
|
2015-12-20 15:00:43 -06:00
|
|
|
($err:expr, $span:expr, $($message:tt)*) => ({
|
|
|
|
($err).span_help($span, &format!($($message)*));
|
2014-10-28 18:59:36 -05:00
|
|
|
})
|
2014-11-14 11:18:10 -06:00
|
|
|
}
|
2014-10-28 18:59:36 -05:00
|
|
|
|
2015-02-24 08:07:54 -06:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! fileline_help {
|
2015-12-20 15:00:43 -06:00
|
|
|
($err:expr, $span:expr, $($message:tt)*) => ({
|
|
|
|
($err).fileline_help($span, &format!($($message)*));
|
2015-02-24 08:07:54 -06:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2014-07-11 11:54:01 -05:00
|
|
|
#[macro_export]
|
2014-11-14 11:18:10 -06:00
|
|
|
macro_rules! register_diagnostics {
|
2014-07-11 11:54:01 -05:00
|
|
|
($($code:tt),*) => (
|
2014-11-14 11:18:10 -06:00
|
|
|
$(register_diagnostic! { $code })*
|
2015-07-16 06:16:59 -05:00
|
|
|
);
|
|
|
|
($($code:tt),*,) => (
|
|
|
|
$(register_diagnostic! { $code })*
|
2014-07-11 11:54:01 -05:00
|
|
|
)
|
2014-11-14 11:18:10 -06:00
|
|
|
}
|
|
|
|
|
2015-01-17 19:20:24 -06:00
|
|
|
#[macro_export]
|
|
|
|
macro_rules! register_long_diagnostics {
|
|
|
|
($($code:tt: $description:tt),*) => (
|
|
|
|
$(register_diagnostic! { $code, $description })*
|
2015-07-17 04:21:05 -05:00
|
|
|
);
|
|
|
|
($($code:tt: $description:tt),*,) => (
|
|
|
|
$(register_diagnostic! { $code, $description })*
|
2015-01-17 19:20:24 -06:00
|
|
|
)
|
|
|
|
}
|