From 710407b11dce7274ccf16b072fb500b9e5d4fb15 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 28 Dec 2020 19:53:00 +0800 Subject: Fix mbe fail to pass expr with attr --- crates/mbe/src/tests.rs | 12 ++++++++++++ crates/parser/src/grammar.rs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'crates') diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 6cd0ed205..0147506c7 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 f08c8bab7..63cc90027 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) { -- cgit v1.2.3 From 877c251bef9bd4ac8ccab971786847bd4f28cc34 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Mon, 28 Dec 2020 20:08:50 +0800 Subject: Fixed old failed test due to new fixes --- crates/hir_def/src/nameres/tests/macros.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index f9bf5bc72..e5e9e8ca1 100644 --- a/crates/hir_def/src/nameres/tests/macros.rs +++ b/crates/hir_def/src/nameres/tests/macros.rs @@ -677,7 +677,7 @@ fn macro_expansion_overflow() { r#" macro_rules! a { ($e:expr; $($t:tt)*) => { - b!($($t)*); + b!(static = (); $($t)*); }; () => {}; } @@ -689,7 +689,7 @@ macro_rules! b { () => {}; } -b! { static = #[] (); } +b! { static = #[] ();} "#, expect![[r#" crate -- cgit v1.2.3