-
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
Fix parsing of erroneously placed semicolons #125276
Conversation
Don't worry and welome to rustc :) |
items.push(item); | ||
last = items.last().map(|x| &**x); |
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.
A ref on top of a deref seems redundant. Maybe replace &**x
with just *x
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.
Reborrowing to convert the Option<&P<Item>>
into an Option<&Item>
. as_deref
doesn't work here.
while let Some(item) = self.parse_item(ForceCollect::No)? { | ||
self.maybe_consume_incorrect_semicolon(Some(&item)); | ||
|
||
// There shouldn't be any semicolons before or afer items. |
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.
// There shouldn't be any semicolons before or afer items. | |
// There shouldn't be any stray semicolons before or afer items. |
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.
and afer → after :)
// `parse_item` consumes the appropriate semicolons so any leftover is an error. | ||
let mut last = None; | ||
loop { | ||
while self.maybe_consume_incorrect_semicolon(last) {} // Eat all bad semicolons |
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 we just do the following and remove the local binding last
outright?
while self.maybe_consume_incorrect_semicolon(last) {} // Eat all bad semicolons | |
while self.maybe_consume_incorrect_semicolon(items.last().as_deref()) {} // Eat all bad semicolons |
@rustbot ready |
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.
plz squash
@rustbot ready |
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!
@bors r+ rollup |
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
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#122665 (Add some tests for public-private dependencies.) - rust-lang#123122 (Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.) - rust-lang#125276 (Fix parsing of erroneously placed semicolons) - rust-lang#125310 (Move ~100 tests from tests/ui to subdirs) - rust-lang#125357 (Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs`) - rust-lang#125369 (Don't do cc detection for synthetic targets) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#123122 (Fix incorrect suggestion for undeclared hrtb lifetimes in where clauses.) - rust-lang#123492 (add pull request template asking for relevant tracking issues) - rust-lang#125276 (Fix parsing of erroneously placed semicolons) - rust-lang#125310 (Move ~100 tests from tests/ui to subdirs) - rust-lang#125357 (Migrate `run-make/rustdoc-scrape-examples-multiple` to `rmake.rs`) - rust-lang#125369 (Don't do cc detection for synthetic targets) r? `@ghost` `@rustbot` modify labels: rollup
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
This closes #124935, is a continuation of #125245 after rebasing #125117.
Thanks @gurry for your code and sorry for making it confusing :P
r? fmease