about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-05 20:59:31 +0000
committerGitHub <noreply@github.com>2021-03-05 20:59:31 +0000
commit750d3cb84678b23a55092f2e4726e48ead37a9ff (patch)
treec07742b3121cb50f90535b042c7e4e114f5d3720
parent94012e24e038bc1b96e06638b6e2b38852a510eb (diff)
parent20eda09712f0c4cd701575d125122472252820db (diff)
Merge #7887
7887: Fix fail to parse :: for meta in mbe r=edwin0cheng a=edwin0cheng

fixes #7886

bors r+

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
-rw-r--r--crates/mbe/src/tests.rs3
-rw-r--r--crates/parser/src/grammar.rs3
2 files changed, 4 insertions, 2 deletions
diff --git a/crates/mbe/src/tests.rs b/crates/mbe/src/tests.rs
index 5c641ebf28e..08acd4ac257 100644
--- a/crates/mbe/src/tests.rs
+++ b/crates/mbe/src/tests.rs
@@ -954,7 +954,8 @@ fn test_meta() {
     .assert_expand_items(
         r#"foo! { cfg(target_os = "windows") }"#,
         r#"# [cfg (target_os = "windows")] fn bar () {}"#,
-    );
+    )
+    .assert_expand_items(r#"foo! { hello::world }"#, r#"# [hello :: world] fn bar () {}"#);
 }
 
 #[test]
diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs
index 6913e9ec2f3..6159d064c73 100644
--- a/crates/parser/src/grammar.rs
+++ b/crates/parser/src/grammar.rs
@@ -95,7 +95,7 @@ pub(crate) mod fragments {
                 // https://doc.rust-lang.org/reference/paths.html#simple-paths
                 // The start of an meta must be a simple path
                 match p.current() {
-                    IDENT | T![::] | T![super] | T![self] | T![crate] => p.bump_any(),
+                    IDENT | T![super] | T![self] | T![crate] => p.bump_any(),
                     T![=] => {
                         p.bump_any();
                         match p.current() {
@@ -105,6 +105,7 @@ pub(crate) mod fragments {
                         }
                         break;
                     }
+                    _ if p.at(T![::]) => p.bump(T![::]),
                     _ => break,
                 }
             }