-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Fix parsing of erroneously placed semicolons #125245
Conversation
There were two issues here: a. we weren't consuming any semicolons that occurred at the start of a mod before all the items b. we weren't consuming multiple consecutive wrongly placed semicolons; we consumed only one and then tried to consume an item.
Sorry about that, I didn't realize the author of the other PR was fixing a GH issue for precisely the same reason, I'll tell them to link issues in the future (I've already added a fixes keyword to their PR descr). |
No worries @fmease. Thanks 😊 |
What? I don't think I've fixed the issue, have I? The PR I made existed because I'm very new and I wanted to document and make some improvements to the parser while I was reading the code in order to fix an unrelated issue :P |
Oops, that's embarrassing 😅 I should've looked closer at the changes, I just saw both PRs swapping the order of @gurry Please proceed |
I reimplemented this after rebasing master. |
Thanks @dev-ardi |
Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks `@gurry` for your code and sorry for making it confusing :P r? fmease
Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks ``@gurry`` for your code and sorry for making it confusing :P r? fmease
Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks ```@gurry``` for your code and sorry for making it confusing :P r? fmease
Rollup merge of rust-lang#125276 - dev-ardi:no-main-diag, r=fmease Fix parsing of erroneously placed semicolons This closes rust-lang#124935, is a continuation of rust-lang#125245 after rebasing rust-lang#125117. Thanks ```@gurry``` for your code and sorry for making it confusing :P r? fmease
Fixes #124935
The issue occurred with code like this where a semicolon occurs at the start before any items:
The root cause lay in the parser wherein we weren't consuming the semicolon and getting it out of the way before trying to parse the item (i.e.
main
in this case). This meant we attempted to parse the semicolon as an item which failed and we stopped parsing further because of that failure. The end result was that nomain
was recorded in the AST which lead to theno main
error later on in one of the lints.This PR ensures that we consume all consecutive semicolons (as there could be more than one) before trying to parse an item.