2 macro_rules! register_diagnostic {
3 ($code:tt, $description:tt) => (__register_diagnostic! { $code, $description });
4 ($code:tt) => (__register_diagnostic! { $code })
8 macro_rules! span_fatal {
9 ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
10 __diagnostic_used!($code);
11 $session.span_fatal_with_code(
13 &format!($($message)*),
14 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
20 macro_rules! span_err {
21 ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
22 __diagnostic_used!($code);
23 $session.span_err_with_code(
25 &format!($($message)*),
26 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
32 macro_rules! span_warn {
33 ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
34 __diagnostic_used!($code);
35 $session.span_warn_with_code(
37 &format!($($message)*),
38 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
44 macro_rules! struct_err {
45 ($session:expr, $code:ident, $($message:tt)*) => ({
46 __diagnostic_used!($code);
47 $session.struct_err_with_code(
48 &format!($($message)*),
49 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
55 macro_rules! span_err_or_warn {
56 ($is_warning:expr, $session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
57 __diagnostic_used!($code);
59 $session.span_warn_with_code(
61 &format!($($message)*),
62 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
65 $session.span_err_with_code(
67 &format!($($message)*),
68 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
75 macro_rules! struct_span_fatal {
76 ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
77 __diagnostic_used!($code);
78 $session.struct_span_fatal_with_code(
80 &format!($($message)*),
81 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
87 macro_rules! struct_span_err {
88 ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
89 __diagnostic_used!($code);
90 $session.struct_span_err_with_code(
92 &format!($($message)*),
93 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
99 macro_rules! stringify_error_code {
101 __diagnostic_used!($code);
102 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned())
107 macro_rules! type_error_struct {
108 ($session:expr, $span:expr, $typ:expr, $code:ident, $($message:tt)*) => ({
109 if $typ.references_error() {
110 $session.diagnostic().struct_dummy()
112 struct_span_err!($session, $span, $code, $($message)*)
118 macro_rules! struct_span_warn {
119 ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
120 __diagnostic_used!($code);
121 $session.struct_span_warn_with_code(
123 &format!($($message)*),
124 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
130 macro_rules! struct_span_err_or_warn {
131 ($is_warning:expr, $session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
132 __diagnostic_used!($code);
134 $session.struct_span_warn_with_code(
136 &format!($($message)*),
137 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
140 $session.struct_span_err_with_code(
142 &format!($($message)*),
143 $crate::errors::DiagnosticId::Error(stringify!($code).to_owned()),
150 macro_rules! span_note {
151 ($err:expr, $span:expr, $($message:tt)*) => ({
152 ($err).span_note($span, &format!($($message)*));
157 macro_rules! span_help {
158 ($err:expr, $span:expr, $($message:tt)*) => ({
159 ($err).span_help($span, &format!($($message)*));
165 ($err:expr, $($message:tt)*) => ({
166 ($err).help(&format!($($message)*));
171 macro_rules! register_diagnostics {
173 $(register_diagnostic! { $code })*
175 ($($code:tt),*,) => (
176 $(register_diagnostic! { $code })*
181 macro_rules! register_long_diagnostics {
182 ($($code:tt: $description:tt),*) => (
183 $(register_diagnostic! { $code, $description })*
185 ($($code:tt: $description:tt),*,) => (
186 $(register_diagnostic! { $code, $description })*