diff --git a/tests/ui/cast_lossless_float.fixed b/tests/ui/cast_lossless_float.fixed index 709d58b59..32a9c1c4a 100644 --- a/tests/ui/cast_lossless_float.fixed +++ b/tests/ui/cast_lossless_float.fixed @@ -6,24 +6,24 @@ fn main() { // Test clippy::cast_lossless with casts to floating-point types let x0 = 1i8; - f32::from(x0); - f64::from(x0); + let _ = f32::from(x0); + let _ = f64::from(x0); let x1 = 1u8; - f32::from(x1); - f64::from(x1); + let _ = f32::from(x1); + let _ = f64::from(x1); let x2 = 1i16; - f32::from(x2); - f64::from(x2); + let _ = f32::from(x2); + let _ = f64::from(x2); let x3 = 1u16; - f32::from(x3); - f64::from(x3); + let _ = f32::from(x3); + let _ = f64::from(x3); let x4 = 1i32; - f64::from(x4); + let _ = f64::from(x4); let x5 = 1u32; - f64::from(x5); + let _ = f64::from(x5); // Test with casts from floating-point types - f64::from(1.0f32); + let _ = f64::from(1.0f32); } // The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const, diff --git a/tests/ui/cast_lossless_float.rs b/tests/ui/cast_lossless_float.rs index eb0aab886..6f5ddcfe0 100644 --- a/tests/ui/cast_lossless_float.rs +++ b/tests/ui/cast_lossless_float.rs @@ -6,24 +6,24 @@ fn main() { // Test clippy::cast_lossless with casts to floating-point types let x0 = 1i8; - x0 as f32; - x0 as f64; + let _ = x0 as f32; + let _ = x0 as f64; let x1 = 1u8; - x1 as f32; - x1 as f64; + let _ = x1 as f32; + let _ = x1 as f64; let x2 = 1i16; - x2 as f32; - x2 as f64; + let _ = x2 as f32; + let _ = x2 as f64; let x3 = 1u16; - x3 as f32; - x3 as f64; + let _ = x3 as f32; + let _ = x3 as f64; let x4 = 1i32; - x4 as f64; + let _ = x4 as f64; let x5 = 1u32; - x5 as f64; + let _ = x5 as f64; // Test with casts from floating-point types - 1.0f32 as f64; + let _ = 1.0f32 as f64; } // The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const, diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr index 0ed09f308..8326d40be 100644 --- a/tests/ui/cast_lossless_float.stderr +++ b/tests/ui/cast_lossless_float.stderr @@ -1,70 +1,70 @@ error: casting `i8` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:9:5 + --> $DIR/cast_lossless_float.rs:9:13 | -LL | x0 as f32; - | ^^^^^^^^^ help: try: `f32::from(x0)` +LL | let _ = x0 as f32; + | ^^^^^^^^^ help: try: `f32::from(x0)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting `i8` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:10:5 + --> $DIR/cast_lossless_float.rs:10:13 | -LL | x0 as f64; - | ^^^^^^^^^ help: try: `f64::from(x0)` +LL | let _ = x0 as f64; + | ^^^^^^^^^ help: try: `f64::from(x0)` error: casting `u8` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:12:5 + --> $DIR/cast_lossless_float.rs:12:13 | -LL | x1 as f32; - | ^^^^^^^^^ help: try: `f32::from(x1)` +LL | let _ = x1 as f32; + | ^^^^^^^^^ help: try: `f32::from(x1)` error: casting `u8` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:13:5 + --> $DIR/cast_lossless_float.rs:13:13 | -LL | x1 as f64; - | ^^^^^^^^^ help: try: `f64::from(x1)` +LL | let _ = x1 as f64; + | ^^^^^^^^^ help: try: `f64::from(x1)` error: casting `i16` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:15:5 + --> $DIR/cast_lossless_float.rs:15:13 | -LL | x2 as f32; - | ^^^^^^^^^ help: try: `f32::from(x2)` +LL | let _ = x2 as f32; + | ^^^^^^^^^ help: try: `f32::from(x2)` error: casting `i16` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:16:5 + --> $DIR/cast_lossless_float.rs:16:13 | -LL | x2 as f64; - | ^^^^^^^^^ help: try: `f64::from(x2)` +LL | let _ = x2 as f64; + | ^^^^^^^^^ help: try: `f64::from(x2)` error: casting `u16` to `f32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:18:5 + --> $DIR/cast_lossless_float.rs:18:13 | -LL | x3 as f32; - | ^^^^^^^^^ help: try: `f32::from(x3)` +LL | let _ = x3 as f32; + | ^^^^^^^^^ help: try: `f32::from(x3)` error: casting `u16` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:19:5 + --> $DIR/cast_lossless_float.rs:19:13 | -LL | x3 as f64; - | ^^^^^^^^^ help: try: `f64::from(x3)` +LL | let _ = x3 as f64; + | ^^^^^^^^^ help: try: `f64::from(x3)` error: casting `i32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:21:5 + --> $DIR/cast_lossless_float.rs:21:13 | -LL | x4 as f64; - | ^^^^^^^^^ help: try: `f64::from(x4)` +LL | let _ = x4 as f64; + | ^^^^^^^^^ help: try: `f64::from(x4)` error: casting `u32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:23:5 + --> $DIR/cast_lossless_float.rs:23:13 | -LL | x5 as f64; - | ^^^^^^^^^ help: try: `f64::from(x5)` +LL | let _ = x5 as f64; + | ^^^^^^^^^ help: try: `f64::from(x5)` error: casting `f32` to `f64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_float.rs:26:5 + --> $DIR/cast_lossless_float.rs:26:13 | -LL | 1.0f32 as f64; - | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` +LL | let _ = 1.0f32 as f64; + | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` error: aborting due to 11 previous errors diff --git a/tests/ui/cast_lossless_integer.fixed b/tests/ui/cast_lossless_integer.fixed index 03e49adb1..72a708b40 100644 --- a/tests/ui/cast_lossless_integer.fixed +++ b/tests/ui/cast_lossless_integer.fixed @@ -5,27 +5,27 @@ fn main() { // Test clippy::cast_lossless with casts to integer types - i16::from(1i8); - i32::from(1i8); - i64::from(1i8); - i16::from(1u8); - i32::from(1u8); - i64::from(1u8); - u16::from(1u8); - u32::from(1u8); - u64::from(1u8); - i32::from(1i16); - i64::from(1i16); - i32::from(1u16); - i64::from(1u16); - u32::from(1u16); - u64::from(1u16); - i64::from(1i32); - i64::from(1u32); - u64::from(1u32); + let _ = i16::from(1i8); + let _ = i32::from(1i8); + let _ = i64::from(1i8); + let _ = i16::from(1u8); + let _ = i32::from(1u8); + let _ = i64::from(1u8); + let _ = u16::from(1u8); + let _ = u32::from(1u8); + let _ = u64::from(1u8); + let _ = i32::from(1i16); + let _ = i64::from(1i16); + let _ = i32::from(1u16); + let _ = i64::from(1u16); + let _ = u32::from(1u16); + let _ = u64::from(1u16); + let _ = i64::from(1i32); + let _ = i64::from(1u32); + let _ = u64::from(1u32); // Test with an expression wrapped in parens - u16::from(1u8 + 1u8); + let _ = u16::from(1u8 + 1u8); } // The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const, diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs index 6a984d245..34bb47181 100644 --- a/tests/ui/cast_lossless_integer.rs +++ b/tests/ui/cast_lossless_integer.rs @@ -5,27 +5,27 @@ fn main() { // Test clippy::cast_lossless with casts to integer types - 1i8 as i16; - 1i8 as i32; - 1i8 as i64; - 1u8 as i16; - 1u8 as i32; - 1u8 as i64; - 1u8 as u16; - 1u8 as u32; - 1u8 as u64; - 1i16 as i32; - 1i16 as i64; - 1u16 as i32; - 1u16 as i64; - 1u16 as u32; - 1u16 as u64; - 1i32 as i64; - 1u32 as i64; - 1u32 as u64; + let _ = 1i8 as i16; + let _ = 1i8 as i32; + let _ = 1i8 as i64; + let _ = 1u8 as i16; + let _ = 1u8 as i32; + let _ = 1u8 as i64; + let _ = 1u8 as u16; + let _ = 1u8 as u32; + let _ = 1u8 as u64; + let _ = 1i16 as i32; + let _ = 1i16 as i64; + let _ = 1u16 as i32; + let _ = 1u16 as i64; + let _ = 1u16 as u32; + let _ = 1u16 as u64; + let _ = 1i32 as i64; + let _ = 1u32 as i64; + let _ = 1u32 as u64; // Test with an expression wrapped in parens - (1u8 + 1u8) as u16; + let _ = (1u8 + 1u8) as u16; } // The lint would suggest using `f64::from(input)` here but the `XX::from` function is not const, diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr index 8e2890f9c..721b94876 100644 --- a/tests/ui/cast_lossless_integer.stderr +++ b/tests/ui/cast_lossless_integer.stderr @@ -1,118 +1,118 @@ error: casting `i8` to `i16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:8:5 + --> $DIR/cast_lossless_integer.rs:8:13 | -LL | 1i8 as i16; - | ^^^^^^^^^^ help: try: `i16::from(1i8)` +LL | let _ = 1i8 as i16; + | ^^^^^^^^^^ help: try: `i16::from(1i8)` | = note: `-D clippy::cast-lossless` implied by `-D warnings` error: casting `i8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:9:5 + --> $DIR/cast_lossless_integer.rs:9:13 | -LL | 1i8 as i32; - | ^^^^^^^^^^ help: try: `i32::from(1i8)` +LL | let _ = 1i8 as i32; + | ^^^^^^^^^^ help: try: `i32::from(1i8)` error: casting `i8` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:10:5 + --> $DIR/cast_lossless_integer.rs:10:13 | -LL | 1i8 as i64; - | ^^^^^^^^^^ help: try: `i64::from(1i8)` +LL | let _ = 1i8 as i64; + | ^^^^^^^^^^ help: try: `i64::from(1i8)` error: casting `u8` to `i16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:11:5 + --> $DIR/cast_lossless_integer.rs:11:13 | -LL | 1u8 as i16; - | ^^^^^^^^^^ help: try: `i16::from(1u8)` +LL | let _ = 1u8 as i16; + | ^^^^^^^^^^ help: try: `i16::from(1u8)` error: casting `u8` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:12:5 + --> $DIR/cast_lossless_integer.rs:12:13 | -LL | 1u8 as i32; - | ^^^^^^^^^^ help: try: `i32::from(1u8)` +LL | let _ = 1u8 as i32; + | ^^^^^^^^^^ help: try: `i32::from(1u8)` error: casting `u8` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:13:5 + --> $DIR/cast_lossless_integer.rs:13:13 | -LL | 1u8 as i64; - | ^^^^^^^^^^ help: try: `i64::from(1u8)` +LL | let _ = 1u8 as i64; + | ^^^^^^^^^^ help: try: `i64::from(1u8)` error: casting `u8` to `u16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:14:5 + --> $DIR/cast_lossless_integer.rs:14:13 | -LL | 1u8 as u16; - | ^^^^^^^^^^ help: try: `u16::from(1u8)` +LL | let _ = 1u8 as u16; + | ^^^^^^^^^^ help: try: `u16::from(1u8)` error: casting `u8` to `u32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:15:5 + --> $DIR/cast_lossless_integer.rs:15:13 | -LL | 1u8 as u32; - | ^^^^^^^^^^ help: try: `u32::from(1u8)` +LL | let _ = 1u8 as u32; + | ^^^^^^^^^^ help: try: `u32::from(1u8)` error: casting `u8` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:16:5 + --> $DIR/cast_lossless_integer.rs:16:13 | -LL | 1u8 as u64; - | ^^^^^^^^^^ help: try: `u64::from(1u8)` +LL | let _ = 1u8 as u64; + | ^^^^^^^^^^ help: try: `u64::from(1u8)` error: casting `i16` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:17:5 + --> $DIR/cast_lossless_integer.rs:17:13 | -LL | 1i16 as i32; - | ^^^^^^^^^^^ help: try: `i32::from(1i16)` +LL | let _ = 1i16 as i32; + | ^^^^^^^^^^^ help: try: `i32::from(1i16)` error: casting `i16` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:18:5 + --> $DIR/cast_lossless_integer.rs:18:13 | -LL | 1i16 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1i16)` +LL | let _ = 1i16 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1i16)` error: casting `u16` to `i32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:19:5 + --> $DIR/cast_lossless_integer.rs:19:13 | -LL | 1u16 as i32; - | ^^^^^^^^^^^ help: try: `i32::from(1u16)` +LL | let _ = 1u16 as i32; + | ^^^^^^^^^^^ help: try: `i32::from(1u16)` error: casting `u16` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:20:5 + --> $DIR/cast_lossless_integer.rs:20:13 | -LL | 1u16 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1u16)` +LL | let _ = 1u16 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1u16)` error: casting `u16` to `u32` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:21:5 + --> $DIR/cast_lossless_integer.rs:21:13 | -LL | 1u16 as u32; - | ^^^^^^^^^^^ help: try: `u32::from(1u16)` +LL | let _ = 1u16 as u32; + | ^^^^^^^^^^^ help: try: `u32::from(1u16)` error: casting `u16` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:22:5 + --> $DIR/cast_lossless_integer.rs:22:13 | -LL | 1u16 as u64; - | ^^^^^^^^^^^ help: try: `u64::from(1u16)` +LL | let _ = 1u16 as u64; + | ^^^^^^^^^^^ help: try: `u64::from(1u16)` error: casting `i32` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:23:5 + --> $DIR/cast_lossless_integer.rs:23:13 | -LL | 1i32 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1i32)` +LL | let _ = 1i32 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1i32)` error: casting `u32` to `i64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:24:5 + --> $DIR/cast_lossless_integer.rs:24:13 | -LL | 1u32 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1u32)` +LL | let _ = 1u32 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1u32)` error: casting `u32` to `u64` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:25:5 + --> $DIR/cast_lossless_integer.rs:25:13 | -LL | 1u32 as u64; - | ^^^^^^^^^^^ help: try: `u64::from(1u32)` +LL | let _ = 1u32 as u64; + | ^^^^^^^^^^^ help: try: `u64::from(1u32)` error: casting `u8` to `u16` may become silently lossy if you later change the type - --> $DIR/cast_lossless_integer.rs:28:5 + --> $DIR/cast_lossless_integer.rs:28:13 | -LL | (1u8 + 1u8) as u16; - | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` +LL | let _ = (1u8 + 1u8) as u16; + | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` error: aborting due to 19 previous errors