-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Modify str_to_string to be machine-applicable #12871
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
Conversation
clippy_lints/src/strings.rs
Outdated
"consider using `.to_owned()`", | ||
format!("{snippet}.to_owned()"), |
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.
I think having two .to_owned()
here seems a bit redundant? How about just using try
as the help msg instead?
"try",
format!("{snippet}.to_owned()"),
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.
(drive-by comment)
It's worth noting that the rustc-dev-guide
explicitly state that the suggestion message should "be upfront about what the suggestion is" and explicitly say to avoid "did you mean"/"the following" ...
I would also note that in IDEs, users may not have access to the terminal output of the compiler and may only have access to the help message to decide if they should apply the suggestion and "try" is less than helpful is those cases.
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.
...the suggestion message should "be upfront about what the suggestion is"...
Well, my bad, I didn't know that 👀.
But in my defense, there are already fair amount of suggestions with "try" existing in clippy. like nonminimal_bool
, manual_swap
, etc. (there are 170+ of them I think), so I though it would make sense to use it.
...in IDEs, users may not have access to the terminal output of the compiler and may only have access to the help message to decide if they should apply the suggestion and "try" is less than helpful is those cases.
In that case, maybe clippy could use a "clean up" to replace those existing "try"s (including this one) with more helpful messages? But I don't know if that worth the effort.
Thanks for the heads up~
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.
No worries, we also have in rustc
messages that don't follow our own guidelines, so I wouldn't expect Clippy or other tools to follow it to the letter either.
In that case, maybe clippy could use a "clean up" to replace those existing "try"s (including this one) with more helpful messages? But I don't know if that worth the effort.
I'm not on the Clippy team so you would have to ask them out that.
Personally I think that could be long term goal.
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.
LGTM, thanks! ❤️
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Fixes #12768
I'm not sure if there is any potential for edge cases with this - since it only ever acts on
&str
types I can't think of any, and especially since the methods do the same thing anyway.changelog: allow
str_to_string
lint to be automatically applied