mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-14 00:47:16 +00:00
164 lines
7.3 KiB
Text
164 lines
7.3 KiB
Text
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:6:13
|
|
|
|
|
LL | let _ = 1u32.checked_add(1).unwrap_or(u32::max_value());
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)`
|
|
|
|
|
= note: `-D clippy::manual-saturating-arithmetic` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::manual_saturating_arithmetic)]`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:7:13
|
|
|
|
|
LL | let _ = 1u32.checked_add(1).unwrap_or(u32::MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u32.saturating_add(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:8:13
|
|
|
|
|
LL | let _ = 1u8.checked_add(1).unwrap_or(255);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1u8.saturating_add(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:9:13
|
|
|
|
|
LL | let _ = 1u128
|
|
| _____________^
|
|
LL | | .checked_add(1)
|
|
LL | | .unwrap_or(340_282_366_920_938_463_463_374_607_431_768_211_455);
|
|
| |_______________________________________________________________________^ help: consider using `saturating_add`: `1u128.saturating_add(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:14:13
|
|
|
|
|
LL | let _ = 1u32.checked_mul(1).unwrap_or(u32::MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_mul`: `1u32.saturating_mul(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:16:13
|
|
|
|
|
LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::min_value());
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:17:13
|
|
|
|
|
LL | let _ = 1u32.checked_sub(1).unwrap_or(u32::MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u32.saturating_sub(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:18:13
|
|
|
|
|
LL | let _ = 1u8.checked_sub(1).unwrap_or(0);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1u8.saturating_sub(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:22:13
|
|
|
|
|
LL | let _ = 1i32.checked_add(1).unwrap_or(i32::max_value());
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:23:13
|
|
|
|
|
LL | let _ = 1i32.checked_add(1).unwrap_or(i32::MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:24:13
|
|
|
|
|
LL | let _ = 1i8.checked_add(1).unwrap_or(127);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:25:13
|
|
|
|
|
LL | let _ = 1i128
|
|
| _____________^
|
|
LL | | .checked_add(1)
|
|
LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727);
|
|
| |_______________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:28:13
|
|
|
|
|
LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::min_value());
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:29:13
|
|
|
|
|
LL | let _ = 1i32.checked_add(-1).unwrap_or(i32::MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i32.saturating_add(-1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:30:13
|
|
|
|
|
LL | let _ = 1i8.checked_add(-1).unwrap_or(-128);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_add`: `1i8.saturating_add(-1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:31:13
|
|
|
|
|
LL | let _ = 1i128
|
|
| _____________^
|
|
LL | | .checked_add(-1)
|
|
LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728);
|
|
| |________________________________________________________________________^ help: consider using `saturating_add`: `1i128.saturating_add(-1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:38:13
|
|
|
|
|
LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::min_value());
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:39:13
|
|
|
|
|
LL | let _ = 1i32.checked_sub(1).unwrap_or(i32::MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:40:13
|
|
|
|
|
LL | let _ = 1i8.checked_sub(1).unwrap_or(-128);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:41:13
|
|
|
|
|
LL | let _ = 1i128
|
|
| _____________^
|
|
LL | | .checked_sub(1)
|
|
LL | | .unwrap_or(-170_141_183_460_469_231_731_687_303_715_884_105_728);
|
|
| |________________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:44:13
|
|
|
|
|
LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::max_value());
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:45:13
|
|
|
|
|
LL | let _ = 1i32.checked_sub(-1).unwrap_or(i32::MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i32.saturating_sub(-1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:46:13
|
|
|
|
|
LL | let _ = 1i8.checked_sub(-1).unwrap_or(127);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `saturating_sub`: `1i8.saturating_sub(-1)`
|
|
|
|
error: manual saturating arithmetic
|
|
--> tests/ui/manual_saturating_arithmetic.rs:47:13
|
|
|
|
|
LL | let _ = 1i128
|
|
| _____________^
|
|
LL | | .checked_sub(-1)
|
|
LL | | .unwrap_or(170_141_183_460_469_231_731_687_303_715_884_105_727);
|
|
| |_______________________________________________________________________^ help: consider using `saturating_sub`: `1i128.saturating_sub(-1)`
|
|
|
|
error: aborting due to 24 previous errors
|
|
|