Skip to content

Instantly share code, notes, and snippets.

@venkatagiri
Last active July 18, 2017 21:18
Error Index Gen
register_long_diagnostics! {
E001: r##"hello"##,
E002: r##"world"##,
}
register_diagnostics! {
E003,
E004
}
#![feature(trace_macros)]
trace_macros!(true);
fn main() {
macro_rules! register_diagnostic {
($code:tt, $description:tt) => { println!( "code is {}", stringify!($code)); };
($code:tt) => { println!( "code is {}", stringify!($code)); }
}
macro_rules! register_diagnostics {
($($code:tt),*) => {
$(register_diagnostic! { $code })*
};
($($code:tt),*,) => {
$(register_diagnostic! { $code })*
};
}
macro_rules! register_long_diagnostics {
($($code:tt: $description:tt),*) => {
$(register_diagnostic! { $code, $description })*
};
($($code:tt: $description:tt),*,) => {
$(register_diagnostic! { $code, $description })*
};
}
#[path = "diagnostics.rs"] mod diags;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment