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
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-09-02 11:13:25 -05:00
|
|
|
macro_rules! pat_macro {
|
2017-09-02 10:21:13 -05:00
|
|
|
() => {
|
2017-09-02 11:13:25 -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);
|
2017-09-02 11:13:25 -05:00
|
|
|
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
|
|
|
|
2021-07-17 13:13:50 -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() {}
|