mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Recover from leading comma in tuple pat and expr
This commit is contained in:
parent
42450d2511
commit
7d1bf7023d
7 changed files with 89 additions and 4 deletions
|
@ -184,6 +184,16 @@ fn tuple_expr(p: &mut Parser<'_>) -> CompletedMarker {
|
|||
|
||||
let mut saw_comma = false;
|
||||
let mut saw_expr = false;
|
||||
|
||||
// test_err tuple_expr_leading_comma
|
||||
// fn foo() {
|
||||
// (,);
|
||||
// }
|
||||
if p.eat(T![,]) {
|
||||
p.error("expected expression");
|
||||
saw_comma = true;
|
||||
}
|
||||
|
||||
while !p.at(EOF) && !p.at(T![')']) {
|
||||
saw_expr = true;
|
||||
|
||||
|
|
|
@ -413,6 +413,16 @@ fn tuple_pat(p: &mut Parser<'_>) -> CompletedMarker {
|
|||
let mut has_comma = false;
|
||||
let mut has_pat = false;
|
||||
let mut has_rest = false;
|
||||
|
||||
// test_err tuple_pat_leading_comma
|
||||
// fn foo() {
|
||||
// let (,);
|
||||
// }
|
||||
if p.eat(T![,]) {
|
||||
p.error("expected pattern");
|
||||
has_comma = true;
|
||||
}
|
||||
|
||||
while !p.at(EOF) && !p.at(T![')']) {
|
||||
has_pat = true;
|
||||
if !p.at_ts(PAT_TOP_FIRST) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue