mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-24 05:33:27 +00:00
29 lines
1.1 KiB
Text
29 lines
1.1 KiB
Text
error: manual arithmetic check found
|
|
--> tests/ui/manual_arithmetic_check.rs:9:18
|
|
|
|
|
LL | let result = if a > b { a - b } else { 0 };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)`
|
|
|
|
|
= note: `-D clippy::implicit-saturating-sub` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::implicit_saturating_sub)]`
|
|
|
|
error: manual arithmetic check found
|
|
--> tests/ui/manual_arithmetic_check.rs:11:18
|
|
|
|
|
LL | let result = if b < a { a - b } else { 0 };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)`
|
|
|
|
error: manual arithmetic check found
|
|
--> tests/ui/manual_arithmetic_check.rs:14:18
|
|
|
|
|
LL | let result = if a < b { 0 } else { a - b };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)`
|
|
|
|
error: manual arithmetic check found
|
|
--> tests/ui/manual_arithmetic_check.rs:16:18
|
|
|
|
|
LL | let result = if b > a { 0 } else { a - b };
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `a.saturating_sub(b)`
|
|
|
|
error: aborting due to 4 previous errors
|
|
|