diff options
Diffstat (limited to 'tests/ui/macros/stmt_expr_attr_macro_parse.rs')
-rw-r--r-- | tests/ui/macros/stmt_expr_attr_macro_parse.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/ui/macros/stmt_expr_attr_macro_parse.rs b/tests/ui/macros/stmt_expr_attr_macro_parse.rs new file mode 100644 index 000000000..570191d2c --- /dev/null +++ b/tests/ui/macros/stmt_expr_attr_macro_parse.rs @@ -0,0 +1,25 @@ +// run-pass +#![allow(unused_macro_rules)] + +macro_rules! m { + ($e:expr) => { + "expr includes attr" + }; + (#[$attr:meta] $e:expr) => { + "expr excludes attr" + } +} + +macro_rules! n { + (#[$attr:meta] $e:expr) => { + "expr excludes attr" + }; + ($e:expr) => { + "expr includes attr" + } +} + +fn main() { + assert_eq!(m!(#[attr] 1), "expr includes attr"); + assert_eq!(n!(#[attr] 1), "expr excludes attr"); +} |