-
Notifications
You must be signed in to change notification settings - Fork 1.6k
shadow_unrelated seems to get confused in nested maps #10780
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
I was just trying out |
DJMcNab
added a commit
to DJMcNab/xilem
that referenced
this issue
Nov 12, 2024
Note, this fix is only excluding the false positives as a result of: rust-lang/rust-clippy#10780 When/if the fix for that trickles onto stable, we can remove the expects
DJMcNab
added a commit
to DJMcNab/xilem
that referenced
this issue
Nov 12, 2024
Note, this fix is only excluding the false positives as a result of: rust-lang/rust-clippy#10780 When/if the fix for that trickles onto stable, we can remove the expects
This was referenced Nov 12, 2024
github-merge-queue bot
pushed a commit
to linebender/xilem
that referenced
this issue
Nov 12, 2024
Note, this fix is only excluding the false positives as a result of: rust-lang/rust-clippy#10780 When/if the fix for that (rust-lang/rust-clippy#13677) trickles onto stable, we can remove the expects.
github-merge-queue bot
pushed a commit
that referenced
this issue
Nov 30, 2024
Fixes #10780 We correctly no longer give a warning when a closure is passed to a method, where one of the arguments to that method uses the variable which would be shadowed by an argument to that closure. Uses is defined loosely as any expression used in the calling expression mentions the shadowee binding (except for the closure itself): ```rust #![deny(clippy::shadow_unrelated)] let x = Some(1); let y = x.map(|x| x + 1); ``` will now succeed. See linebender/xilem#745 - without this change, all of the `expect(shadow_unrelated)` in the repository are met; with it, none of them are. changelog: [`shadow_unrelated`]: Don't treat closures arguments as unrelated when the calling function uses them
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
When I use the same variable name inside a closure passed to
Option.map
as the variable is named,shadow_unrelated
fires, which is odd because this is pretty much the definition of "uses the original value".Lint Name
shadow_unrelated
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
Clippy does not report a problem.
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: