mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-18 02:38:28 +00:00
b0edbca0e6
Add a lint to detect cast to unsigned for abs() and suggest unsigned_abs() to avoid panic when called on MIN.
10 lines
323 B
Text
10 lines
323 B
Text
error: casting the result of `i32::abs()` to u32
|
|
--> $DIR/cast_abs_to_unsigned.rs:6:18
|
|
|
|
|
LL | let y: u32 = x.abs() as u32;
|
|
| ^^^^^^^^^^^^^^ help: replace with: `x.unsigned_abs()`
|
|
|
|
|
= note: `-D clippy::cast-abs-to-unsigned` implied by `-D warnings`
|
|
|
|
error: aborting due to previous error
|
|
|