Skip to content

Fix parsing of erroneously placed semicolons - #125276

Merged
bors merged 1 commit into
rust-lang:masterfrom
oriongonza:no-main-diag
May 21, 2024
Merged

Fix parsing of erroneously placed semicolons#125276
bors merged 1 commit into
rust-lang:masterfrom
oriongonza:no-main-diag

Conversation

@oriongonza

@oriongonzaoriongonza commented May 19, 2024

Copy link
Copy Markdown
Contributor

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

@rustbotrustbot 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
Comment threadcompiler/rustc_parse/src/parser/item.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/item.rs Outdated
Comment threadcompiler/rustc_parse/src/parser/item.rs Outdated
@gurry

Copy link
Copy Markdown
Contributor

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

Don't worry and welome to rustc :)

break;
};
items.push(item);
last = items.last().map(|x| &**x);

Copy link
Copy Markdown
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
Copy Markdown
ContributorAuthor

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
whileself.maybe_consume_incorrect_semicolon(last){}// Eat all bad semicolons
whileself.maybe_consume_incorrect_semicolon(items.last().as_deref()){}// Eat all bad semicolons

@fmeasefmease 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
@oriongonza

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@rustbotrustbot 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

@fmeasefmease left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

plz squash

@oriongonza

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@fmeasefmease left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@fmease

Copy link
Copy Markdown
Member

@bors r+ rollup

@bors

bors commented May 21, 2024

Copy link
Copy Markdown
Collaborator

📌 Commit 972633f has been approved by fmease

It is now in the queue for this repository.

@borsbors 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 closesrust-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 closesrust-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
@fmeasefmease mentioned this pull request May 21, 2024
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:masterMay 21, 2024
@rustbotrustbot 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 closesrust-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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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

@oriongonza@gurry@fmease@bors@rustbot