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 logic in IncrementVisitor #10094

Merged
merged 1 commit into from
Dec 17, 2022
Merged

Conversation

ericwu17
Copy link
Contributor

@ericwu17 ericwu17 commented Dec 16, 2022

There used to be a logical bug where IncrementVisitor would completely stop checking an expression/block after seeing a continue statement.

I am a little unsure of whether my fix to IncrementVisitor is logically sound (I hope it makes sense). Let me know what you think, and thanks in advance for the review!

fixes #10058


changelog: FP: [explicit_counter_loop]: No longer ignores counter changes after continue expressions
#10094

There used to be a logical bug where IncrementVisitor would
completely stop checking an expression/block after seeing a continue
statement. This led to issue rust-lang#10058 where a variable incremented
(or otherwise modified) after any continue statement would still be
considered incremented only once.

The solution is to continue scanning the expression after seeing a
`continue` statement, but increment self.depth so that the Visitor
thinks that the rest of the loop is within a conditional.
@rustbot
Copy link
Collaborator

rustbot commented Dec 16, 2022

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @flip1995 (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Dec 16, 2022
@xFrednet
Copy link
Member

r? @xFrednet

@rustbot rustbot assigned xFrednet and unassigned flip1995 Dec 17, 2022
@xFrednet
Copy link
Member

Hey @ericwu2003, welcome to Clippy! The change looks good to me, thank you for the contribution. I adjusted the changelog entry a bit, to reflect the user-facing change. Other than that, it's perfect. I hope you had fun!

@bors r+

@bors
Copy link
Contributor

bors commented Dec 17, 2022

📌 Commit 97c12e0 has been approved by xFrednet

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Dec 17, 2022

⌛ Testing commit 97c12e0 with merge b62319c...

@bors
Copy link
Contributor

bors commented Dec 17, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: xFrednet
Pushing b62319c to master...

@bors bors merged commit b62319c into rust-lang:master Dec 17, 2022
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

explicit_counter_loop emitted incorrectly when using guard clauses with continue.
5 participants