-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
don't lint field_reassign when field in closure #10143
don't lint field_reassign when field in closure #10143
Conversation
r? @Manishearth (rustbot has picked a reviewer for you, use r? to override) |
This commit makes the ContainsName struct visit all interior expressions, which means that ContainsName will return true even if `name` is used in a closure within `expr`.
45cd57a
to
8de011f
Compare
Could someone advise on whether I should be using @rustbot label: +E-help-wanted |
clippy_utils/src/lib.rs
Outdated
pub name: Symbol, | ||
pub result: bool, | ||
} | ||
|
||
impl<'tcx> Visitor<'tcx> for ContainsName { | ||
impl<'a, 'tcx> Visitor<'tcx> for ContainsName<'a, 'tcx> { | ||
type NestedFilter = nested_filter::All; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think it should be OnlyBodies here, All includes things like impls, etc, whereas OnlyBodies just covers closures and consts.
We actually don't want to include consts but that's niche enough and it doesn't hurt to check extra
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks. I made a change to use nested_filter::OnlyBodies
instead.
we only need to check closures, so nestedfilter::All was overkill here.
are you ready for merging, or is this a draft for some other reason too? |
I was ready for merging. Sorry, I forgot to remove the draft marker. |
@bors r+ Thanks!! |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fixes #10136
This change makes the ContainsName struct visit all interior expressions, which means that ContainsName will return true even if
name
is used in a closure withinexpr
.changelog: FP: [
field_reassign_with_default
]: No longer lints cases, where values are initializes from closures capturing struct values#10143