]> git.lizzy.rs Git - rust.git/commitdiff
Merge #7060
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>
Mon, 28 Dec 2020 12:34:19 +0000 (12:34 +0000)
committerGitHub <noreply@github.com>
Mon, 28 Dec 2020 12:34:19 +0000 (12:34 +0000)
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>
crates/hir_def/src/nameres/tests/macros.rs
crates/mbe/src/tests.rs
crates/parser/src/grammar.rs

index f9bf5bc7253f6ac8e0f5e14e1c729589e72bcac7..e5e9e8ca16d3ac118885168e69a15a959bb629b9 100644 (file)
@@ -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
index 9958a33a08d0fffd01802a8bf5e4fda2dacaf6ab..1d9afb4fb8a1b236190380801377dc3ae647ce0c 100644 (file)
@@ -760,6 +760,18 @@ macro_rules! vec {
     );
 }
 
+#[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(
index f08c8bab741f55534fcfe6a8d2cd8d9bc4ac2316..63cc900272ce9c3e833c7e39fc8faf1c9372870a 100644 (file)
@@ -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) {