]> git.lizzy.rs Git - rust.git/blobdiff - crates/parser/src/grammar/patterns.rs
Replace SyntaxKind usage with T! macro where applicable
[rust.git] / crates / parser / src / grammar / patterns.rs
index 796f206e1284fac80d5cab9000d667078014b968..da71498a8f9211465f902fb84765fe1c43dea8e2 100644 (file)
@@ -83,12 +83,13 @@ fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) {
 }
 
 const PAT_RECOVERY_SET: TokenSet =
-    TokenSet::new(&[LET_KW, IF_KW, WHILE_KW, LOOP_KW, MATCH_KW, R_PAREN, COMMA]);
+    TokenSet::new(&[T![let], T![if], T![while], T![loop], T![match], T![')'], T![,]]);
 
 fn atom_pat(p: &mut Parser, recovery_set: TokenSet) -> Option<CompletedMarker> {
     let m = match p.nth(0) {
         T![box] => box_pat(p),
         T![ref] | T![mut] => ident_pat(p, true),
+        T![const] => const_block_pat(p),
         IDENT => match p.nth(1) {
             // Checks the token after an IDENT to see if a pattern is a path (Struct { .. }) or macro
             // (T![x]).
@@ -188,7 +189,7 @@ fn tuple_pat_fields(p: &mut Parser) {
     p.expect(T![')']);
 }
 
-// test record_field_pat_list
+// test record_pat_field_list
 // fn foo() {
 //     let S {} = ();
 //     let S { f, ref mut g } = ();
@@ -208,7 +209,7 @@ fn record_pat_field_list(p: &mut Parser) {
             c => {
                 let m = p.start();
                 match c {
-                    // test record_field_pat
+                    // test record_pat_field
                     // fn foo() {
                     //     let S { 0: 1 } = ();
                     //     let S { x: 1 } = ();
@@ -386,3 +387,16 @@ fn box_pat(p: &mut Parser) -> CompletedMarker {
     pattern_single(p);
     m.complete(p, BOX_PAT)
 }
+
+// test const_block_pat
+// fn main() {
+//     let const { 15 } = ();
+//     let const { foo(); bar() } = ();
+// }
+fn const_block_pat(p: &mut Parser) -> CompletedMarker {
+    assert!(p.at(T![const]));
+    let m = p.start();
+    p.bump(T![const]);
+    expressions::block_expr(p);
+    m.complete(p, CONST_BLOCK_PAT)
+}