diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 6cd0ed2053..0147506c79 100644 --- a/crates/mbe/src/tests.rs +++ b/crates/mbe/src/tests.rs @@ -760,6 +760,18 @@ fn test_last_expr() { ); } +#[test] +fn test_expr_with_attr() { + parse_macro( + r#" +macro_rules! m { + ($a:expr) => {0} +} +"#, + ) + .assert_expand_items("m!(#[allow(a)]())", "0"); +} + #[test] fn test_ty() { parse_macro( diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index f08c8bab74..63cc900272 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -59,7 +59,7 @@ pub(crate) mod fragments { }; pub(crate) fn expr(p: &mut Parser) { - let _ = expressions::expr(p); + let _ = expressions::expr_with_attrs(p); } pub(crate) fn stmt(p: &mut Parser) {