RS.CLIPPY.PANICKING_OVERFLOW_CHECKS
Overflow checks which will panic in debug mode
This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: panicking_overflow_checks. Copyright ©2025 The Rust Team. All rights reserved.
What it does
Detects C-style underflow/overflow checks.
Why is this bad?
These checks will, by default, panic in debug builds rather than check whether the operation caused an overflow.
Example
if a + b < a {
// handle overflow
}
Use instead:
if a.checked_add(b).is_none() {
// handle overflow
}
Or:
if a.overflowing_add(b).1 {
// handle overflow
}
Past names
- overflow_check_conditional