WiP: Fix wrong_self_convention false positive (#3414) #3562
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current fix passes tests but is likely too broad:
It is not limited to types with generic
Deref
impls, and modifiesSelfKind.matches()
which is also used for the should_implement_trait lint.I am a bit stuck on detecting generic Deref impls: I started copying
has_debug_impl()
before realizing that function takesty::Ty
instead ofhir::Ty
. I also haven't figured out how to get or check the associated type of a trait impl.The issue only mentions
into_*
wanting self by value, but could there be similar false positives with phrases for which the lint wants&self
or&mut self
?Related: It doesn't look like there's a lint against inherent methods with
self
on types that deref to an unknown (generic) type. Should I add one?