-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
new lint: unnecessary_fallible_conversions
#11669
Conversation
r? @Jarcho (rustbot has picked a reviewer for you, use r? to override) |
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 for the implementation of my suggested lint!
☔ The latest upstream changes (presumably #11698) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
Looks good overall. Just a couple of small nits. If you don't feel like rewording things it's workable the way it is.
Thanks for the small cleanup. @bors r+ |
@bors r- |
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
Just a maybe unrelated comment on this, but would a lint that finds unnecessary TryFrom implementations that instead could be just From be implemented alongside this one?
Easy to detect when the return value is always |
Looks like a possible lint. If you want this, please open an issue or if you want to get into Clippy development consider opening a PR for it :) |
This fixes the clippy lint firing on macOS on the conversion which needed for portability. For some reason, the logic in rust-lang/rust-clippy#11669 to avoid an overlap is not working.
Closes #11577
A new lint that looks for calls such as
i64::try_from(1i32)
and suggestsi64::from(1i32)
. See lint description (and linked issue) for more details for why.There's a tiny bit of overlap with the
useless_conversion
lint, in that the other one warnsT::try_from(T)
(i.e., fallibly converting to the same type), so this lint ignores cases likei32::try_from(1i32)
to avoid emitting two warnings for the same expression.Also, funnily enough, with this one exception, this lint would warn on exactly every case in the
useless_conversion_try
ui test thatuseless_conversion
didn't cover (but never two warnings at the same time), which is neat. I did add an#![allow]
though since we don't want interleaved warnings from multiple lints in the same uitest.changelog: new lint:
unnecessary_fallible_conversions