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.rs | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 52a08c4fb1..f40c515fa0 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -620,30 +620,15 @@ fn arg_list(p: &mut Parser<'_>) { // fn main() { // foo(#[attr] 92) // } - p.bump(T!['(']); - while !p.at(T![')']) && !p.at(EOF) { - if p.at(T![,]) { - // Recover if an argument is missing and only got a delimiter, - // e.g. `(a, , b)`. - p.error("expected expression"); - p.bump(T![,]); - continue; - } - - if expr(p).is_none() { - break; - } - if !p.at(T![,]) { - if p.at_ts(EXPR_FIRST.union(ATTRIBUTE_FIRST)) { - p.error(format!("expected {:?}", T![,])); - } else { - break; - } - } else { - p.bump(T![,]); - } - } - p.expect(T![')']); + delimited( + p, + T!['('], + T![')'], + T![,], + || "expected expression".into(), + EXPR_FIRST.union(ATTRIBUTE_FIRST), + |p| expr(p).is_some(), + ); m.complete(p, ARG_LIST); } |