Skip to content

Commit e2344e7

Browse files
committed
fix: Use pattern recovery set when parsing ident patterns
1 parent 1b12021 commit e2344e7

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

crates/parser/src/grammar/patterns.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,16 @@ fn record_pat_field(p: &mut Parser) {
223223
p.bump(T![:]);
224224
pattern(p);
225225
}
226-
T![.] => {
227-
if p.at(T![..]) {
228-
p.bump(T![..]);
229-
} else {
230-
ident_pat(p, false);
231-
}
232-
}
233226
T![box] => {
234227
// FIXME: not all box patterns should be allowed
235228
box_pat(p);
236229
}
237-
_ => {
230+
T![ref] | T![mut] | IDENT => {
238231
ident_pat(p, false);
239232
}
233+
_ => {
234+
p.err_and_bump("expected identifier");
235+
}
240236
}
241237
}
242238

@@ -405,10 +401,11 @@ fn pat_list(p: &mut Parser, ket: SyntaxKind) {
405401
// let ref mut f @ g @ _ = ();
406402
// }
407403
fn ident_pat(p: &mut Parser, with_at: bool) -> CompletedMarker {
404+
assert!(matches!(p.current(), T![ref] | T![mut] | IDENT));
408405
let m = p.start();
409406
p.eat(T![ref]);
410407
p.eat(T![mut]);
411-
name(p);
408+
name_r(p, PAT_RECOVERY_SET);
412409
if with_at && p.eat(T![@]) {
413410
pattern_single(p);
414411
}

0 commit comments

Comments
 (0)