diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-12-28 12:34:19 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-28 12:34:19 +0000 |
| commit | 77ad203a719be074e81485af7a4fb02fac6cbf61 (patch) | |
| tree | 69f29dec5bfb8f9d3b86e0e05ccb9d88193fb02d | |
| parent | 99ec2f623d4446bcc0befe17a98db9c7062b8009 (diff) | |
| parent | 877c251bef9bd4ac8ccab971786847bd4f28cc34 (diff) | |
| download | rust-77ad203a719be074e81485af7a4fb02fac6cbf61.tar.gz rust-77ad203a719be074e81485af7a4fb02fac6cbf61.zip | |
Merge #7060
7060: Fix mbe fail to pass expr with attr r=edwin0cheng a=edwin0cheng bors r+ Fixes #5896 Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
| -rw-r--r-- | crates/hir_def/src/nameres/tests/macros.rs | 4 | ||||
| -rw-r--r-- | crates/mbe/src/tests.rs | 12 | ||||
| -rw-r--r-- | crates/parser/src/grammar.rs | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/crates/hir_def/src/nameres/tests/macros.rs b/crates/hir_def/src/nameres/tests/macros.rs index f9bf5bc7253..e5e9e8ca16d 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 diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs index 9958a33a08d..1d9afb4fb8a 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) { |
