[arithmetic_side_effects] Division by NonZeroU*
cannot panic
#11392
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
Division (
/
and%
, i.e.div()
andrem()
) implemented for the following pairs of types:(u8, core::num::NonZeroU8)
(u16, core::num::NonZeroU16)
(u32, core::num::NonZeroU32)
(u64, core::num::NonZeroU64)
(u128, core::num::NonZeroU128)
(usize, core::num::NonZeroUsize)
never panics (because the
(x, 0)
and(MIN, -1)
cases are impossible), but thearithmetic_side_effects
lint currently flags them.(Note: I recognize that this is a very specific case and don't know if it can be fixed)
Lint Name
arithmetic_side_effects
Reproducer
I tried this code:
(note: compiles and runs fine, output:
)
I saw this happen:
I expected to see this happen:
No warning
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: