cast_possible_truncation
could leverage simple patterns
#12781
Labels
C-bug
Category: Clippy is not doing the correct thing
I-false-positive
Issue: The lint was triggered on code it shouldn't have
Summary
When a cast is followed by a trivial check, either by a pattern or condition, we could avoid emitting this link since clippy can know that the cast will always succeed.
Lint Name
cast_possible_truncation
Reproducer
I tried this code: playground link
I saw this happen:
Clippy should not emit this warning, since it should be able to understand from the trivial pattern 1..=255 that the cast will succeed. Note that because this occurs in a constant and
TryFrom
is unstable in constants,TryFrom
cannot be used here.Version
Additional Labels
@rustbot label +I-false-positive
The text was updated successfully, but these errors were encountered: