2018-08-30 07:18:55 -05:00
|
|
|
//@ run-pass
|
2022-04-17 10:00:10 -05:00
|
|
|
#![allow(unused_macro_rules)]
|
|
|
|
|
2015-11-24 07:56:20 -06:00
|
|
|
macro_rules! m {
|
|
|
|
($e:expr) => {
|
|
|
|
"expr includes attr"
|
|
|
|
};
|
|
|
|
(#[$attr:meta] $e:expr) => {
|
|
|
|
"expr excludes attr"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-24 16:03:10 -06:00
|
|
|
macro_rules! n {
|
|
|
|
(#[$attr:meta] $e:expr) => {
|
|
|
|
"expr excludes attr"
|
|
|
|
};
|
|
|
|
($e:expr) => {
|
|
|
|
"expr includes attr"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-24 07:56:20 -06:00
|
|
|
fn main() {
|
2015-11-24 16:03:10 -06:00
|
|
|
assert_eq!(m!(#[attr] 1), "expr includes attr");
|
|
|
|
assert_eq!(n!(#[attr] 1), "expr excludes attr");
|
2015-11-24 07:56:20 -06:00
|
|
|
}
|