Clippy · Correctness
Overflow check that panics before detecting overflow
clippy::panicking_overflow_checks
Use checked_add or overflowing_add: in debug builds the addition panics before the comparison can detect overflow.
- Category
- Correctness
- Default level
- warn
- Tier
- P1
- Producer
- Clippy
- Diff scope
- line
Not a defect when
There is effectively no such case: in builds with overflow checks the addition panics before the comparison runs, so checked_add or overflowing_add is always the correct form.
What it reads
Clippy, with the compiler behind it. The only pass that compiles.
Tier
Serious: worth interrupting other work for.
The tier bounds how severe a rule may be; its category bounds the tier.Diff scope
The changed line itself.
What--scope contextual looks at to decide whether a change caused the finding.Change it
Turn it off, or make it blocking, without touching the code it flags:
rust-doctor --rule clippy::panicking_overflow_checks=off .
rust-doctor --rule clippy::panicking_overflow_checks=error .