]> git.lizzy.rs Git - rust.git/blobdiff - crates/parser/src/grammar/items.rs
Wrap remaining self/super/crate in Name{Ref}
[rust.git] / crates / parser / src / grammar / items.rs
index 72b73f89174d60faf249cffe52dfe50b38b4e78c..1d894e907be280a3d3afcdf09072e01634a044ec 100644 (file)
@@ -27,19 +27,19 @@ pub(super) fn mod_contents(p: &mut Parser, stop_on_r_curly: bool) {
 }
 
 pub(super) const ITEM_RECOVERY_SET: TokenSet = TokenSet::new(&[
-    FN_KW,
-    STRUCT_KW,
-    ENUM_KW,
-    IMPL_KW,
-    TRAIT_KW,
-    CONST_KW,
-    STATIC_KW,
-    LET_KW,
-    MOD_KW,
-    PUB_KW,
-    CRATE_KW,
-    USE_KW,
-    MACRO_KW,
+    T![fn],
+    T![struct],
+    T![enum],
+    T![impl],
+    T![trait],
+    T![const],
+    T![static],
+    T![let],
+    T![mod],
+    T![pub],
+    T![crate],
+    T![use],
+    T![macro],
     T![;],
 ]);
 
@@ -270,7 +270,9 @@ fn extern_crate(p: &mut Parser, m: Marker) {
     p.bump(T![crate]);
 
     if p.at(T![self]) {
+        let m = p.start();
         p.bump(T![self]);
+        m.complete(p, NAME_REF);
     } else {
         name_ref(p);
     }
@@ -389,10 +391,15 @@ fn macro_rules(p: &mut Parser, m: Marker) {
     }
 
     match p.current() {
-        T!['{'] => {
+        // test macro_rules_non_brace
+        // macro_rules! m ( ($i:ident) => {} );
+        // macro_rules! m [ ($i:ident) => {} ];
+        T!['['] | T!['('] => {
             token_tree(p);
+            p.expect(T![;]);
         }
-        _ => p.error("expected `{`"),
+        T!['{'] => token_tree(p),
+        _ => p.error("expected `{`, `[`, `(`"),
     }
     m.complete(p, MACRO_RULES);
 }