Rules / TAU-N001
Checked arithmetic
decided by Clippy kernel deny core deny edge warn
Applies to tests: no
Exceptions:
#[expect] + reasonWhy
Integer overflow and division by zero either panic or wrap silently depending on build profile; both are logic errors agents rarely test.
Fix
Use checked_* and return an error on None, or saturating_*/wrapping_* when that behaviour is the specification. Say which in a comment. In a kernel crate this is a proof obligation: a recorded proof that the function never fails discharges it (cargo tauten obligations).
What it checks
Lints: clippy::arithmetic_side_effects, clippy::integer_division
Seen in fixtures
rej-contract-overflow/src/lib.rs core
//! Unchecked arithmetic. /// Next value.#[must_use]pub fn next(x: u8) -> u8 { x + 1}$ cargo tauten check
error[TAU-N001]: arithmetic operation that can potentially result in unexpected side-effects --> rej-contract-overflow/src/lib.rs:6:5 (core crate `rej-contract-overflow`) = rule: Checked arithmetic (decided by Clippy) = fix: Use `checked_*` and return an error on None, or `saturating_*`/`wrapping_*` when that behaviour is the specification. Say which in a comment. In a kernel crate this is a proof obligation: a recorded proof that the function never fails discharges it (`cargo tauten obligations`).rej-contract-overflow (core) expects TAU-N001. Output captured at 0200db3.In the terminal
cargo tauten explain TAU-N001$ cargo tauten explain TAU-N001
TAU-N001: Checked arithmetic Why: Integer overflow and division by zero either panic or wrap silently depending on build profile; both are logic errors agents rarely test. Fix: Use `checked_*` and return an error on None, or `saturating_*`/`wrapping_*` when that behaviour is the specification. Say which in a comment. In a kernel crate this is a proof obligation: a recorded proof that the function never fails discharges it (`cargo tauten obligations`). Decided by: ClippyDecides: No arithmetic that can overflow, divide by zero or truncate silently in linted code.Sees: resolved; complete: yesDoes not see: Code expanded from macros defined in other crates (clippy skips it); code disabled by `cfg`; build scripts.Applies to tests: noExceptions allowed: with #[expect(.., reason)] kernel deny core deny edge warnLints: clippy::arithmetic_side_effects, clippy::integer_division