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

Improve parse item fallback #125388

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dev-ardi
Copy link
Contributor

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

Closes #92615 and closes #101622
Please review the new diagnostics cafefully.

This PR also adds a few more comments to the parser.

@rustbot
Copy link
Collaborator

rustbot commented May 21, 2024

r? @wesleywiser

rustbot has assigned @wesleywiser.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@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 21, 2024
Copy link
Member

@SparrowLii SparrowLii left a comment

Choose a reason for hiding this comment

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

I don't think this PR solves #101622 :(

.dcx()
.struct_span_err(self.token.span, format!("expected item, found {token_str}"));

match self.parse_full_stmt(AttemptLocalParseRecovery::No) {
Copy link
Member

@SparrowLii SparrowLii May 24, 2024

Choose a reason for hiding this comment

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

We'd be better doing more analysis to figure out what went wrong here, rather than treating them all as statements. For example, whether it contains ; in [] can be used to distinguish whether it is an attribute or an array.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave up on trying to detect kinds of expressions as it's very unreliable.

compiler/rustc_parse/src/parser/item.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/parser/item.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/parser/item.rs Outdated Show resolved Hide resolved
compiler/rustc_parse/src/parser/item.rs Outdated Show resolved Hide resolved
@dev-ardi
Copy link
Contributor Author

I don't think this PR solves #101622 :(

It addresses the main point raised in the issue, right?

@dev-ardi dev-ardi force-pushed the improve-parse-item-fallback branch 3 times, most recently from 9a129e5 to 06a1ccf Compare May 31, 2024 15:29
@dev-ardi
Copy link
Contributor Author

@rustbot ready
@SparrowLii I've addressed your concerns and reworked the approach a bit.

@bors
Copy link
Contributor

bors commented Jun 18, 2024

☔ The latest upstream changes (presumably #126049) made this pull request unmergeable. Please resolve the merge conflicts.

@dev-ardi dev-ardi force-pushed the improve-parse-item-fallback branch from 06a1ccf to 1d326d5 Compare June 19, 2024 20:19
@rust-log-analyzer

This comment has been minimized.

@dev-ardi
Copy link
Contributor Author

dev-ardi commented Jun 20, 2024

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 20, 2024
@dev-ardi dev-ardi force-pushed the improve-parse-item-fallback branch 2 times, most recently from 3f2ccd7 to b9ddf53 Compare June 20, 2024 22:31
@dev-ardi dev-ardi force-pushed the improve-parse-item-fallback branch from b9ddf53 to c66b446 Compare July 4, 2024 22:37
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 18, 2024

☔ The latest upstream changes (presumably #127906) made this pull request unmergeable. Please resolve the merge conflicts.

@JohnCSimon
Copy link
Member

@dev-ardi
ping from triage - can you post your status on this PR? This PR has not received an update in a few months.

@dev-ardi
Copy link
Contributor Author

dev-ardi commented Sep 3, 2024

It was left unreviewed for a while so it became full of conflicts. I intend to finish it at some point though...

@dev-ardi dev-ardi force-pushed the improve-parse-item-fallback branch 2 times, most recently from 57d1590 to faf1c5f Compare October 2, 2024 20:18
@dev-ardi
Copy link
Contributor Author

dev-ardi commented Oct 2, 2024

@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 Oct 2, 2024
@rust-log-analyzer

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Poor recovery from pub let x = ... Provide a better error when code is put outside of a function
8 participants