fix(useless_format): improve suggestion - #16595
Conversation
|
r? @llogiq rustbot has assigned @llogiq. Use Why was this reviewer chosen?The reviewer was selected based on:
|
956942e to
61470b0
Compare
61470b0 to
3a22fa5
Compare
This comment has been minimized.
This comment has been minimized.
|
thanks @llogiq, fixed |
|
Thank you! |
|
@llogiq seems like merge queue is being ... resistive |
3a22fa5 to
fcd1e55
Compare
This comment has been minimized.
This comment has been minimized.
|
@llogiq could you try to add it to the merge queue again? |
|
Hm, but clippy lints are supposed to compose, no? If a user runs |
Head branch was pushed to by a user without write access
fcd1e55 to
aec946c
Compare
This comment has been minimized.
This comment has been minimized.
|
@ada4a yes, but clippy is frequently used via rust analyzer, so people would see a suggestion in the IDE, click "fix", and the fix would be flagged again as another fix - i.e. annoying :) @llogiq friendly ping, or let me know if someone else should review this |
|
I think @ada4a is right about the composability issue. Can we fix it within this PR or should we wait for a followup? |
|
@llogiq I am not certain how this PR should be modified... If clippy makes a suggestion, I would think the suggestion should be "as good as possible", rather than relying on a chain of lints, esp if some lints in that chain might have been disabled for various reasons. |
|
@llogiq friendly ping - what should be done here? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
533a114 to
729a91e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
729a91e to
e2f0fe5
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
☔ The latest upstream changes (possibly #17607) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
Fix #3361
Handled test case:
This pull request improves the
useless_formatlint in Clippy by making its suggestions whenformat!is immediately borrowed as a string slice. The changes also refactor how lint messages and suggestions are generated for better clarity and maintainability.Improvements to lint suggestions:
format!is immediately borrowed as&format!("literal")and suggests using the string literal directly, instead of calling.to_string(). This provides a more idiomatic and efficient suggestion.&format!) are handled with the new message; mutable borrows (&mut format!) still suggest.to_string().changelog: [
useless_format]: for&format!("literal")suggest"literal"as a replacement