Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/parser/src/grammar/expressions.rs')
-rw-r--r--crates/parser/src/grammar/expressions.rs29
1 files changed, 20 insertions, 9 deletions
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs
index f40c515fa0..6b660180f8 100644
--- a/crates/parser/src/grammar/expressions.rs
+++ b/crates/parser/src/grammar/expressions.rs
@@ -678,27 +678,38 @@ pub(crate) fn record_expr_field_list(p: &mut Parser<'_>) {
attributes::outer_attrs(p);
match p.current() {
- IDENT | INT_NUMBER => {
+ IDENT | INT_NUMBER if p.nth_at(1, T![::]) => {
// test_err record_literal_missing_ellipsis_recovery
// fn main() {
// S { S::default() }
// }
- if p.nth_at(1, T![::]) {
- m.abandon(p);
- p.expect(T![..]);
- expr(p);
- } else {
+ m.abandon(p);
+ p.expect(T![..]);
+ expr(p);
+ }
+ IDENT | INT_NUMBER => {
+ if p.nth_at(1, T![..]) {
// test_err record_literal_before_ellipsis_recovery
// fn main() {
// S { field ..S::default() }
// }
- if p.nth_at(1, T![:]) || p.nth_at(1, T![..]) {
+ name_ref_or_index(p);
+ p.error("expected `:`");
+ } else {
+ // test_err record_literal_field_eq_recovery
+ // fn main() {
+ // S { field = foo }
+ // }
+ if p.nth_at(1, T![:]) {
+ name_ref_or_index(p);
+ p.bump(T![:]);
+ } else if p.nth_at(1, T![=]) {
name_ref_or_index(p);
- p.expect(T![:]);
+ p.err_and_bump("expected `:`");
}
expr(p);
- m.complete(p, RECORD_EXPR_FIELD);
}
+ m.complete(p, RECORD_EXPR_FIELD);
}
T![.] if p.at(T![..]) => {
m.abandon(p);