mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
fix: Recover from =
in record pattern field
This commit is contained in:
parent
ccccc299c8
commit
bf115a6064
6 changed files with 59 additions and 4 deletions
|
@ -694,7 +694,7 @@ pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
|
|||
// S { field ..S::default() }
|
||||
// }
|
||||
name_ref_or_index(p);
|
||||
p.error("expected colon");
|
||||
p.error("expected `:`");
|
||||
} else {
|
||||
// test_err record_literal_field_eq_recovery
|
||||
// fn main() {
|
||||
|
@ -705,7 +705,7 @@ pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
|
|||
p.bump(T![:]);
|
||||
} else if p.nth_at(1, T![=]) {
|
||||
name_ref_or_index(p);
|
||||
p.err_and_bump("expected colon");
|
||||
p.err_and_bump("expected `:`");
|
||||
}
|
||||
expr(p);
|
||||
}
|
||||
|
|
|
@ -323,6 +323,15 @@ fn record_pat_field(p: &mut Parser<'_>) {
|
|||
p.bump(T![:]);
|
||||
pattern(p);
|
||||
}
|
||||
// test_err record_pat_field_eq_recovery
|
||||
// fn main() {
|
||||
// let S { field = foo };
|
||||
// }
|
||||
IDENT | INT_NUMBER if p.nth(1) == T![=] => {
|
||||
name_ref_or_index(p);
|
||||
p.err_and_bump("expected `:`");
|
||||
pattern(p);
|
||||
}
|
||||
T![box] => {
|
||||
// FIXME: not all box patterns should be allowed
|
||||
box_pat(p);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue