diff options
| author | Edwin Cheng <edwin0cheng@gmail.com> | 2020-12-28 19:53:00 +0800 |
|---|---|---|
| committer | Edwin Cheng <edwin0cheng@gmail.com> | 2020-12-28 19:53:00 +0800 |
| commit | 710407b11dce7274ccf16b072fb500b9e5d4fb15 (patch) | |
| tree | 13d1b64bdd37db998cc8a24434146efdfb02415a | |
| parent | 1d530756ed7ba175ec32ff71247072798dc9a748 (diff) | |
| download | rust-710407b11dce7274ccf16b072fb500b9e5d4fb15.tar.gz rust-710407b11dce7274ccf16b072fb500b9e5d4fb15.zip | |
Fix mbe fail to pass expr with attr
| -rw-r--r-- | crates/mbe/src/tests.rs | 12 | ||||
| -rw-r--r-- | crates/parser/src/grammar.rs | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 6cd0ed20539..0147506c79f 100644 --- a/crates/mbe/src/tests.rs +++ b/crates/mbe/src/tests.rs @@ -761,6 +761,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( r#" diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index f08c8bab741..63cc900272c 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) { |
