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 shadow_unrelated's behaviour with closures #13677

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

Conversation

DJMcNab
Copy link
Contributor

@DJMcNab DJMcNab commented Nov 12, 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):

#![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

@rustbot
Copy link
Collaborator

rustbot commented Nov 12, 2024

r? @Jarcho

rustbot has assigned @Jarcho.
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 the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Nov 12, 2024
github-merge-queue bot pushed a commit to linebender/xilem that referenced this pull request 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.
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.

shadow_unrelated seems to get confused in nested maps
3 participants