-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Improve string_to_string
lint in case it is in a map call
#14396
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
Improve string_to_string
lint in case it is in a map call
#14396
Conversation
1ab177f
to
b4a6b9c
Compare
Finally fixed dogfood. :D |
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, this is an nice new message.
One thing that bothers me a bit is the HIR node to which the new message applies. Shouldn't it be associated with the .map()
call node, since this is what the message suggests to rewrite with .cloned()
?
At some point, we'll need the node anyway if we are going to propose an autofix.
b4a6b9c
to
0ffc6cf
Compare
I kept the current formatting: it's always underlining the caller. I can send a follow-up to fix that if you want? |
Yes, but it also only proposed to modify the caller itself, never the enclosing map expression.
I would say that the message probably belongs to the |
I updated to emit a suggestion on the method call. |
@GuillaumeGomez Did you miss the proposal in #14396 (comment)? Right now, |
I completely missed it, sorry. Updating. |
Added the suggested improvement, thanks! |
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.
Some additional comments.
7ac1752
to
269b913
Compare
So in the end, I just removed the comment in the ui test. ^^' |
Fixes #14175.
There are two "big" cases to handle:
.map(|x| x.to_string())
and.map(String::to_string)
. If the closure has more than one expression, we should not suggest.cloned()
.changelog: Improve
string_to_string
lint in case it is in a map callr? @samueltardieu