mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 21:43:37 +00:00
Auto merge of #12090 - Veykril:recov, r=Veykril
fix: Use pattern recovery set when parsing ident patterns
This commit is contained in:
commit
ab8159b0b2
1 changed files with 6 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue