Closed
Description
Summary
arithmetic_side_effects
lint correctly considers operations such as (somevar: u64) / 2
as non-side-effectful. However as soon as 2
is extracted into a constant, the lint starts firing.
I don't think it is critical that we handle complex constant evaluation here, but it would be nice if it handled at least basic literals like that so that this lint didn't become a motivation to inline magic numbers into the code.
Lint Name
arithmetic_side_effects
Reproducer
I tried this code:
#![deny(clippy::arithmetic_side_effects)]
fn foo(input: u64) -> u64 {
const A: u64 = 1;
input / A
}
I saw this happen:
error: arithmetic operation that can potentially result in unexpected side-effects
--> src/lib.rs:5:5
|
5 | input / A
| ^^^^^^^^^
Version
rustc nightly / 0.1.68 (2023-01-17 3984bc5) on the playground
Additional Labels
No response