rust/tests/ui/cast_abs_to_unsigned.fixed
Paolo Borelli b0edbca0e6 new lint cast_abs_to_unsigned
Add a lint to detect cast to unsigned for abs() and suggest
unsigned_abs() to avoid panic when called on MIN.
2022-04-07 11:28:14 +02:00

9 lines
180 B
Rust

// run-rustfix
#![warn(clippy::cast_abs_to_unsigned)]
fn main() {
let x: i32 = -42;
let y: u32 = x.unsigned_abs();
println!("The absolute value of {} is {}", x, y);
}