Skip to content
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

Merged
merged 1 commit into from
May 21, 2024

Conversation

dev-ardi
Copy link
Contributor

@dev-ardi dev-ardi commented May 19, 2024

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 19, 2024
@gurry
Copy link
Contributor

gurry commented May 20, 2024

Thanks @gurry for your code and sorry for making it confusing :P

Don't worry and welome to rustc :)

items.push(item);
last = items.last().map(|x| &**x);
Copy link
Contributor

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

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// There shouldn't be any semicolons before or afer items.
// There shouldn't be any stray semicolons before or afer items.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and aferafter :)

// `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
Copy link
Member

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?

Suggested change
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

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 20, 2024
@dev-ardi
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 20, 2024
Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz squash

@dev-ardi
Copy link
Contributor Author

@rustbot ready

Copy link
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fmease
Copy link
Member

fmease commented May 21, 2024

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 21, 2024

📌 Commit 972633f has been approved by fmease

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 21, 2024
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request May 21, 2024
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
fmease added a commit to fmease/rust that referenced this pull request May 21, 2024
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
bors added a commit to rust-lang-ci/rust that referenced this pull request May 21, 2024
…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
bors added a commit to rust-lang-ci/rust that referenced this pull request May 21, 2024
…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
@bors bors merged commit bfa98d3 into rust-lang:master May 21, 2024
6 checks passed
@rustbot rustbot added this to the 1.80.0 milestone May 21, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request May 21, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong diagnostic: main function not found in crate
5 participants