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
|
|
||
| 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.
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.
👍 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
nameis 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