about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2022-04-27 19:08:50 +0200
committerLukas Wirth <lukastw97@gmail.com>2022-04-27 19:08:50 +0200
commite2344e78f36f399b94893f4947c943101b29958b (patch)
treec3e4a3eec0fd6fc8fa015e1f885d3489d8b34f1a
parent1b120216de987f2e7700b7707ef6b5d5b5545d94 (diff)
downloadrust-e2344e78f36f399b94893f4947c943101b29958b.tar.gz
rust-e2344e78f36f399b94893f4947c943101b29958b.zip
fix: Use pattern recovery set when parsing ident patterns
-rw-r--r--crates/parser/src/grammar/patterns.rs15
1 files changed, 6 insertions, 9 deletions
diff --git a/crates/parser/src/grammar/patterns.rs b/crates/parser/src/grammar/patterns.rs
index 70ff87b2386..1f622b32e5b 100644
--- a/crates/parser/src/grammar/patterns.rs
+++ b/crates/parser/src/grammar/patterns.rs
@@ -223,20 +223,16 @@ fn record_pat_field(p: &mut Parser) {
             p.bump(T![:]);
             pattern(p);
         }
-        T![.] => {
-            if p.at(T![..]) {
-                p.bump(T![..]);
-            } else {
-                ident_pat(p, false);
-            }
-        }
         T![box] => {
             // FIXME: not all box patterns should be allowed
             box_pat(p);
         }
-        _ => {
+        T![ref] | T![mut] | IDENT => {
             ident_pat(p, false);
         }
+        _ => {
+            p.err_and_bump("expected identifier");
+        }
     }
 }
 
@@ -405,10 +401,11 @@ fn pat_list(p: &mut Parser, ket: SyntaxKind) {
 //     let ref mut f @ g @ _ = ();
 // }
 fn ident_pat(p: &mut Parser, with_at: bool) -> CompletedMarker {
+    assert!(matches!(p.current(), T![ref] | T![mut] | IDENT));
     let m = p.start();
     p.eat(T![ref]);
     p.eat(T![mut]);
-    name(p);
+    name_r(p, PAT_RECOVERY_SET);
     if with_at && p.eat(T![@]) {
         pattern_single(p);
     }