new lint: unnecessary_fallible_conversions#11669
Conversation
|
r? @Jarcho (rustbot has picked a reviewer for you, use r? to override) |
sgued
left a comment
There was a problem hiding this comment.
Thanks for the implementation of my suggested lint!
|
☔ The latest upstream changes (presumably #11698) made this pull request unmergeable. Please resolve the merge conflicts. |
Jarcho
left a comment
There was a problem hiding this comment.
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_conversionlint, 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_tryui test thatuseless_conversiondidn'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