-
Notifications
You must be signed in to change notification settings - Fork 1.7k
explicit_counter_loop emitted incorrectly when using guard clauses with continue. #10058
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
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Comments
ericwu17
added a commit
to ericwu17/rust-clippy
that referenced
this issue
Dec 16, 2022
There used to be a logical bug where IncrementVisitor would completely stop checking an expression/block after seeing a continue statement. This led to issues such as rust-lang#10058 where a variable incremented (or otherwise modified) after any continue statement could 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.
ericwu17
added a commit
to ericwu17/rust-clippy
that referenced
this issue
Dec 16, 2022
There used to be a logical bug where IncrementVisitor would completely stop checking an expression/block after seeing a continue statement. This led to issues such as rust-lang#10058 where a variable incremented (or otherwise modified) after any continue statement could 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.
ericwu17
added a commit
to ericwu17/rust-clippy
that referenced
this issue
Dec 16, 2022
There used to be a logical bug where IncrementVisitor would completely stop checking an expression/block after seeing a continue statement. This led to issues such as rust-lang#10058 where a variable incremented (or otherwise modified) after any continue statement could 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.
ericwu17
added a commit
to ericwu17/rust-clippy
that referenced
this issue
Dec 16, 2022
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.
chansuke
pushed a commit
to chansuke/rust-clippy
that referenced
this issue
Dec 17, 2022
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
Just came across this. Not a huge issue, but kind of annoying.
I'll often use
continue
to build guard clauses in my for loops and it seems clippy doesn't realise that this makes everything below it conditional.Clippy version:
clippy 0.1.65 (897e375 2022-11-02)
Lint Name
explicit_counter_loop
Reproducer
This is the simplest code I could make to reproduce it.
It does not happen for this code:
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: