Look at adjusted types instead of fn signature types in ptr_arg
#13313
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.
This simplifies the implementation of the
ptr_arg
lint a bit and:Fixes #13308
Fixes #10612
Currently, the lint checks if e.g. a
&String
parameter is only used in contexts where a&str
could work. Part of it worked by looking for path exprs to that parameter in function call position specifically, looking at the callee signature and checking if that parameter type without refs isString
(or one of a bunch of other special cases).This simplified version removes the special casing of function calls and looking at the parameter type and instead just looks at the adjusted type, regardless of the expression it's in. This naturally also covers what the previous version was doing (if the expression is in a function call argument position expecting a
&str
, then it will have that adjustment. If it requires a&String
then it won't have that adjustment and we won't lint).The linked issue was a FP that happened because the previous implementation simply didn't consider projection types in the signature type, but with this simplification we don't really need to consider that (because we aren't looking at function signatures at all anymore -- the
&mut Self::Owned
parameter type ofclone_into
is the already-instantiated and normalized type&mut String
).changelog: none