-
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
Tweak parsing recovery of enums, for exprs and match arm patterns #117565
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
r? @Nilstrieb for parser recovery stuff |
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.
This PR is quite big and changes a lot of things, making it hard to follow and doesn't allow merging the parts that are good already. It also makes it harder to see which test changes are caused by which code changes. Can you split it up into several PRs for the different parts, like enums, for loops and match arms?
8c4ef89
to
6c90f92
Compare
This comment was marked as resolved.
This comment was marked as resolved.
31f08e9
to
2fa7a9a
Compare
I split the commits as much as possible. I didn't bother making the test comments be accurate for each commit, but did include the |
bcb830a
to
9ad3697
Compare
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.
Thanks for splitting, that makes it a lot easier to review. I've already reviewed the first 4 commits and they look good. I'll review the rest later.
If you want those merged already (making your job rebasing this easier) you can split them into a separate PR and r=me it. Or you can wait here if you prefer.
…=Nilstrieb Tweak error and move tests r? `@Nilstrieb` Split off rust-lang#117565.
Rollup merge of rust-lang#117990 - estebank:issue-100825-part-deux, r=Nilstrieb Tweak error and move tests r? `@Nilstrieb` Split off rust-lang#117565.
9ad3697
to
b4b5981
Compare
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.
finally got around to review it fully, thanks for the patience and sorry for the delay, partially missing time and partially also just forgetting about it 💀
one suggestion for an improvement but that can be a follow up
Splitting up the PR into the many commits was definitely very helpful, thanks. For the future, I think you could have gone further and split every semantic change "pattern changes", "for loop changes", "enum changes", would have also made it easier to see the final UI test diff.
} | ||
|
||
fn parse_match_arm_pat_and_guard(&mut self) -> PResult<'a, (P<Pat>, Option<P<Expr>>)> { | ||
if self.token.kind == token::OpenDelim(Delimiter::Parenthesis) { |
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.
To make it obvious that the only semantic difference is in the error path, I'd prefer to move the call to parse_pat_allow_top_alt
out of the if
and move the if down to the error case.
This doesn't have to block the PR and can be done as a follow-up (it wouldn't be too bad if it never happens either, but it would be nice to have it).`
@@ -1,3 +1,4 @@ | |||
// ignore-tidy-filelength |
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.
:(
(not really something this PR has to fix though, but it may be nice to split this file up further in the future, maybe by moving out more diagnostic paths)
Didn't follow all the recovery paths super closely, but I think I got the high level idea and it looks good. Specifically looked out for happy-path regressions, doesn't look like it had any. |
Tweak parsing recovery of enums, for exprs and match arm patterns Tweak recovery of `for (pat in expr) {}` for more accurate spans. When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix rust-lang#100825. When encountering malformed enums, try more localized per-variant parse recovery. Move parser recovery tests to subdirectory.
When encountering match arm (pat if expr) => {}, recover and suggest removing parentheses. Fix rust-lang#100825.
Use the same approach used for match arm patterns.
cfa2921
to
88453aa
Compare
@bors r=Nilstrieb |
Tweak parsing recovery of enums, for exprs and match arm patterns Tweak recovery of `for (pat in expr) {}` for more accurate spans. When encountering `match` arm `(pat if expr) => {}`, recover and suggest removing parentheses. Fix rust-lang#100825. When encountering malformed enums, try more localized per-variant parse recovery. Move parser recovery tests to subdirectory.
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
Finished benchmarking commit (74fccd0): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 672.348s -> 673.65s (0.19%) |
Tweak recovery of
for (pat in expr) {}
for more accurate spans.When encountering
match
arm(pat if expr) => {}
, recover and suggest removing parentheses. Fix #100825.When encountering malformed enums, try more localized per-variant parse recovery.
Move parser recovery tests to subdirectory.