-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recover missing comma after match arm #97823
Conversation
r? @jackh726 (rust-highfive has picked a reviewer for you, use r? to override) |
r? rust-lang/diagnostics |
arrow_span, | ||
"while parsing the `match` arm starting here", | ||
); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this logic be completely replaced with the snapshot
parse attempt unconditionally? Or is it that we have advanced too much already and consumed part of the pattern by now specifically because of &
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, for example, in:
match &Foo {
&Foo { a: 1 } => ()
&Foo { a } => (),
}
we would have consumed the &
token and Foo { .. }
as the operator and RHS of operator &
in the second arm before getting here, which means we have to handle it differently. Specifically, we can't recover so that the next arm parse is bound to be successful.
r=me if deduplication isn't feasible |
@bors r=estebank |
📌 Commit b13eb61 has been approved by |
@bors rollup |
…-arm, r=estebank Recover missing comma after match arm If we're missing a comma after a match arm expression, try parsing another pattern and a following `=>`. If we find both of those, then recover by suggesting to insert a `,`. Fixes rust-lang#80112
Rollup of 5 pull requests Successful merges: - rust-lang#97595 (Remove unwrap from get_vtable) - rust-lang#97597 (Preserve unused pointer to address casts) - rust-lang#97819 (Recover `import` instead of `use` in item) - rust-lang#97823 (Recover missing comma after match arm) - rust-lang#97851 (Use repr(C) when depending on struct layout in ptr tests) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
If we're missing a comma after a match arm expression, try parsing another pattern and a following
=>
. If we find both of those, then recover by suggesting to insert a,
.Fixes #80112