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