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

Do not recover when parsing stmt in cfg-eval. #111054

Merged
merged 1 commit into from
May 18, 2023

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented May 1, 2023

parse_stmt does recovery on its own. When parsing the statement fails, we always get Ok(None) instead of an Err variant with the diagnostic that we can emit.

To avoid this behaviour, we need to opt-out of recovery for cfg_eval.

Fixes #105228

@rustbot
Copy link
Collaborator

rustbot commented May 1, 2023

r? @lcnr

(rustbot has picked a reviewer for you, use r? to override)

@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 1, 2023
@lcnr
Copy link
Contributor

lcnr commented May 3, 2023

r? compiler

@rustbot rustbot assigned b-naber and unassigned lcnr May 3, 2023
@@ -166,7 +166,9 @@ impl CfgEval<'_, '_> {
))
},
Annotatable::Stmt(_) => |parser| {
Ok(Annotatable::Stmt(P(parser.parse_stmt(ForceCollect::Yes)?.unwrap())))
Ok(Annotatable::Stmt(P(parser
.parse_stmt_without_recovery(false, ForceCollect::Yes)?
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that familiar with the macro expansion code, so feel free to re-assign.

But I'm wondering why we even get into the expand call if the parse for the Annotatable failed in the first place. If I understand this correctly this parse is a re-parse (we also get a duplicated error message in the test). Why can't we prevent this to be called when the first parse failed?

@b-naber
Copy link
Contributor

b-naber commented May 18, 2023

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 18, 2023

📌 Commit d56ce8e has been approved by b-naber

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 18, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request May 18, 2023
Do not recover when parsing stmt in cfg-eval.

`parse_stmt` does recovery on its own. When parsing the statement fails, we always get `Ok(None)` instead of an `Err` variant with the diagnostic that we can emit.

To avoid this behaviour, we need to opt-out of recovery for cfg_eval.

Fixes rust-lang#105228
bors added a commit to rust-lang-ci/rust that referenced this pull request May 18, 2023
Rollup of 7 pull requests

Successful merges:

 - rust-lang#110986 (Delay a bug when overwriting fed value.)
 - rust-lang#111054 (Do not recover when parsing stmt in cfg-eval.)
 - rust-lang#111685 (Fix typo in bootstrap command description)
 - rust-lang#111686 (Retire is_foreign_item query.)
 - rust-lang#111695 (Exclude inherent projections from some alias type `match`es)
 - rust-lang#111703 (Merge query property modules into one)
 - rust-lang#111707 (Remove unused `impl<T> WorkerLocal<Vec<T>>`.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ee26abd into rust-lang:master May 18, 2023
@rustbot rustbot added this to the 1.71.0 milestone May 18, 2023
@cjgillot cjgillot deleted the cfg-eval-recover branch May 18, 2023 16:11
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.

ICE with cfg_eval + stmt_expr_attributes
5 participants