rust/tests/ui/macros/trace_faulty_macros.rs

44 lines
767 B
Rust
Raw Normal View History

2017-09-02 10:21:13 -05:00
// compile-flags: -Z trace-macros
2020-03-21 16:12:24 -05:00
#![recursion_limit = "4"]
2017-09-02 10:21:13 -05:00
macro_rules! my_faulty_macro {
() => {
2017-11-20 06:13:27 -06:00
my_faulty_macro!(bcd); //~ ERROR no rules
2017-09-02 10:21:13 -05:00
};
}
macro_rules! pat_macro {
2017-09-02 10:21:13 -05:00
() => {
pat_macro!(A{a:a, b:0, c:_, ..});
};
($a:pat) => {
2020-02-28 21:23:58 -06:00
$a //~ ERROR expected expression
2017-09-02 10:21:13 -05:00
};
}
macro_rules! my_recursive_macro {
() => {
2017-11-20 06:13:27 -06:00
my_recursive_macro!(); //~ ERROR recursion limit
2017-09-02 10:21:13 -05:00
};
}
macro_rules! my_macro {
2020-03-21 16:12:24 -05:00
() => {};
2017-09-02 10:21:13 -05:00
}
fn main() {
my_faulty_macro!();
my_recursive_macro!();
test!();
non_exisiting!();
derive!(Debug);
let a = pat_macro!();
2017-09-02 10:21:13 -05:00
}
#[my_macro]
2020-03-21 16:12:24 -05:00
fn use_bang_macro_as_attr() {}
2017-09-02 10:21:13 -05:00
#[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s
2020-03-21 16:12:24 -05:00
fn use_derive_macro_as_attr() {}