From 94f8fc3a8cf13ba9cfafe9c2bab5350185744f7d Mon Sep 17 00:00:00 2001 From: Philipp Hansch Date: Sat, 6 Jan 2018 00:23:28 +0100 Subject: [PATCH] Split up casting UI tests Part of #2038 --- tests/ui/cast.rs | 49 ---- tests/ui/cast.stderr | 312 ++------------------------ tests/ui/cast_lossless_float.rs | 15 ++ tests/ui/cast_lossless_float.stderr | 62 +++++ tests/ui/cast_lossless_integer.rs | 24 ++ tests/ui/cast_lossless_integer.stderr | 110 +++++++++ tests/ui/cast_size.rs | 23 ++ tests/ui/cast_size.stderr | 122 ++++++++++ 8 files changed, 371 insertions(+), 346 deletions(-) create mode 100644 tests/ui/cast_lossless_float.rs create mode 100644 tests/ui/cast_lossless_float.stderr create mode 100644 tests/ui/cast_lossless_integer.rs create mode 100644 tests/ui/cast_lossless_integer.stderr create mode 100644 tests/ui/cast_size.rs create mode 100644 tests/ui/cast_size.stderr diff --git a/tests/ui/cast.rs b/tests/ui/cast.rs index 1ad4630989dd..833e5a557807 100644 --- a/tests/ui/cast.rs +++ b/tests/ui/cast.rs @@ -25,36 +25,6 @@ fn main() { 1u32 as i32; 1u64 as i64; 1usize as isize; - // Test 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; - // Test cast_lossless with casts to floating-point types - 1i8 as f32; - 1i8 as f64; - 1u8 as f32; - 1u8 as f64; - 1i16 as f32; - 1i16 as f64; - 1u16 as f32; - 1u16 as f64; - 1i32 as f64; - 1u32 as f64; // Test cast_lossless with casts from floating-point types 1.0f32 as f64; // Test cast_lossless with an expression wrapped in parens @@ -63,25 +33,6 @@ fn main() { 1i32 as u32; 1isize as usize; // Extra checks for *size - // Casting from *size - 1isize as i8; - 1isize as f64; - 1usize as f64; - 1isize as f32; - 1usize as f32; - 1isize as i32; - 1isize as u32; - 1usize as u32; - 1usize as i32; - // Casting to *size - 1i64 as isize; - 1i64 as usize; - 1u64 as isize; - 1u64 as usize; - 1u32 as isize; - 1u32 as usize; // Should not trigger any lint - 1i32 as isize; // Neither should this - 1i32 as usize; // Test cast_unnecessary 1i32 as i32; 1f32 as f32; diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index 5e7ed6fae99c..ac409a813cce 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -132,331 +132,49 @@ error: casting usize to isize may wrap around the value 27 | 1usize as isize; | ^^^^^^^^^^^^^^^ -error: casting i8 to i16 may become silently lossy if types change +error: casting f32 to f64 may become silently lossy if types change --> $DIR/cast.rs:29:5 | -29 | 1i8 as i16; - | ^^^^^^^^^^ help: try: `i16::from(1i8)` +29 | 1.0f32 as f64; + | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` | = note: `-D cast-lossless` implied by `-D warnings` -error: casting i8 to i32 may become silently lossy if types change - --> $DIR/cast.rs:30:5 - | -30 | 1i8 as i32; - | ^^^^^^^^^^ help: try: `i32::from(1i8)` - -error: casting i8 to i64 may become silently lossy if types change - --> $DIR/cast.rs:31:5 - | -31 | 1i8 as i64; - | ^^^^^^^^^^ help: try: `i64::from(1i8)` - -error: casting u8 to i16 may become silently lossy if types change - --> $DIR/cast.rs:32:5 - | -32 | 1u8 as i16; - | ^^^^^^^^^^ help: try: `i16::from(1u8)` - -error: casting u8 to i32 may become silently lossy if types change - --> $DIR/cast.rs:33:5 - | -33 | 1u8 as i32; - | ^^^^^^^^^^ help: try: `i32::from(1u8)` - -error: casting u8 to i64 may become silently lossy if types change - --> $DIR/cast.rs:34:5 - | -34 | 1u8 as i64; - | ^^^^^^^^^^ help: try: `i64::from(1u8)` - error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast.rs:35:5 - | -35 | 1u8 as u16; - | ^^^^^^^^^^ help: try: `u16::from(1u8)` - -error: casting u8 to u32 may become silently lossy if types change - --> $DIR/cast.rs:36:5 - | -36 | 1u8 as u32; - | ^^^^^^^^^^ help: try: `u32::from(1u8)` - -error: casting u8 to u64 may become silently lossy if types change - --> $DIR/cast.rs:37:5 - | -37 | 1u8 as u64; - | ^^^^^^^^^^ help: try: `u64::from(1u8)` - -error: casting i16 to i32 may become silently lossy if types change - --> $DIR/cast.rs:38:5 - | -38 | 1i16 as i32; - | ^^^^^^^^^^^ help: try: `i32::from(1i16)` - -error: casting i16 to i64 may become silently lossy if types change - --> $DIR/cast.rs:39:5 - | -39 | 1i16 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1i16)` - -error: casting u16 to i32 may become silently lossy if types change - --> $DIR/cast.rs:40:5 - | -40 | 1u16 as i32; - | ^^^^^^^^^^^ help: try: `i32::from(1u16)` - -error: casting u16 to i64 may become silently lossy if types change - --> $DIR/cast.rs:41:5 - | -41 | 1u16 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1u16)` - -error: casting u16 to u32 may become silently lossy if types change - --> $DIR/cast.rs:42:5 - | -42 | 1u16 as u32; - | ^^^^^^^^^^^ help: try: `u32::from(1u16)` - -error: casting u16 to u64 may become silently lossy if types change - --> $DIR/cast.rs:43:5 - | -43 | 1u16 as u64; - | ^^^^^^^^^^^ help: try: `u64::from(1u16)` - -error: casting i32 to i64 may become silently lossy if types change - --> $DIR/cast.rs:44:5 - | -44 | 1i32 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1i32)` - -error: casting u32 to i64 may become silently lossy if types change - --> $DIR/cast.rs:45:5 - | -45 | 1u32 as i64; - | ^^^^^^^^^^^ help: try: `i64::from(1u32)` - -error: casting u32 to u64 may become silently lossy if types change - --> $DIR/cast.rs:46:5 - | -46 | 1u32 as u64; - | ^^^^^^^^^^^ help: try: `u64::from(1u32)` - -error: casting i8 to f32 may become silently lossy if types change - --> $DIR/cast.rs:48:5 - | -48 | 1i8 as f32; - | ^^^^^^^^^^ help: try: `f32::from(1i8)` - -error: casting i8 to f64 may become silently lossy if types change - --> $DIR/cast.rs:49:5 - | -49 | 1i8 as f64; - | ^^^^^^^^^^ help: try: `f64::from(1i8)` - -error: casting u8 to f32 may become silently lossy if types change - --> $DIR/cast.rs:50:5 - | -50 | 1u8 as f32; - | ^^^^^^^^^^ help: try: `f32::from(1u8)` - -error: casting u8 to f64 may become silently lossy if types change - --> $DIR/cast.rs:51:5 - | -51 | 1u8 as f64; - | ^^^^^^^^^^ help: try: `f64::from(1u8)` - -error: casting i16 to f32 may become silently lossy if types change - --> $DIR/cast.rs:52:5 - | -52 | 1i16 as f32; - | ^^^^^^^^^^^ help: try: `f32::from(1i16)` - -error: casting i16 to f64 may become silently lossy if types change - --> $DIR/cast.rs:53:5 - | -53 | 1i16 as f64; - | ^^^^^^^^^^^ help: try: `f64::from(1i16)` - -error: casting u16 to f32 may become silently lossy if types change - --> $DIR/cast.rs:54:5 - | -54 | 1u16 as f32; - | ^^^^^^^^^^^ help: try: `f32::from(1u16)` - -error: casting u16 to f64 may become silently lossy if types change - --> $DIR/cast.rs:55:5 - | -55 | 1u16 as f64; - | ^^^^^^^^^^^ help: try: `f64::from(1u16)` - -error: casting i32 to f64 may become silently lossy if types change - --> $DIR/cast.rs:56:5 - | -56 | 1i32 as f64; - | ^^^^^^^^^^^ help: try: `f64::from(1i32)` - -error: casting u32 to f64 may become silently lossy if types change - --> $DIR/cast.rs:57:5 - | -57 | 1u32 as f64; - | ^^^^^^^^^^^ help: try: `f64::from(1u32)` - -error: casting f32 to f64 may become silently lossy if types change - --> $DIR/cast.rs:59:5 - | -59 | 1.0f32 as f64; - | ^^^^^^^^^^^^^ help: try: `f64::from(1.0f32)` - -error: casting u8 to u16 may become silently lossy if types change - --> $DIR/cast.rs:61:5 + --> $DIR/cast.rs:31:5 | -61 | (1u8 + 1u8) as u16; +31 | (1u8 + 1u8) as u16; | ^^^^^^^^^^^^^^^^^^ help: try: `u16::from(1u8 + 1u8)` error: casting i32 to u32 may lose the sign of the value - --> $DIR/cast.rs:63:5 + --> $DIR/cast.rs:33:5 | -63 | 1i32 as u32; +33 | 1i32 as u32; | ^^^^^^^^^^^ error: casting isize to usize may lose the sign of the value - --> $DIR/cast.rs:64:5 + --> $DIR/cast.rs:34:5 | -64 | 1isize as usize; +34 | 1isize as usize; | ^^^^^^^^^^^^^^^ -error: casting isize to i8 may truncate the value - --> $DIR/cast.rs:67:5 - | -67 | 1isize as i8; - | ^^^^^^^^^^^^ - -error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast.rs:68:5 - | -68 | 1isize as f64; - | ^^^^^^^^^^^^^ - -error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) - --> $DIR/cast.rs:69:5 - | -69 | 1usize as f64; - | ^^^^^^^^^^^^^ - -error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:70:5 - | -70 | 1isize as f32; - | ^^^^^^^^^^^^^ - -error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) - --> $DIR/cast.rs:71:5 - | -71 | 1usize as f32; - | ^^^^^^^^^^^^^ - -error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:72:5 - | -72 | 1isize as i32; - | ^^^^^^^^^^^^^ - -error: casting isize to u32 may lose the sign of the value - --> $DIR/cast.rs:73:5 - | -73 | 1isize as u32; - | ^^^^^^^^^^^^^ - -error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:73:5 - | -73 | 1isize as u32; - | ^^^^^^^^^^^^^ - -error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:74:5 - | -74 | 1usize as u32; - | ^^^^^^^^^^^^^ - -error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:75:5 - | -75 | 1usize as i32; - | ^^^^^^^^^^^^^ - -error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:75:5 - | -75 | 1usize as i32; - | ^^^^^^^^^^^^^ - -error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:77:5 - | -77 | 1i64 as isize; - | ^^^^^^^^^^^^^ - -error: casting i64 to usize may lose the sign of the value - --> $DIR/cast.rs:78:5 - | -78 | 1i64 as usize; - | ^^^^^^^^^^^^^ - -error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:78:5 - | -78 | 1i64 as usize; - | ^^^^^^^^^^^^^ - -error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:79:5 - | -79 | 1u64 as isize; - | ^^^^^^^^^^^^^ - -error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers - --> $DIR/cast.rs:79:5 - | -79 | 1u64 as isize; - | ^^^^^^^^^^^^^ - -error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:80:5 - | -80 | 1u64 as usize; - | ^^^^^^^^^^^^^ - -error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers - --> $DIR/cast.rs:81:5 - | -81 | 1u32 as isize; - | ^^^^^^^^^^^^^ - -error: casting i32 to usize may lose the sign of the value - --> $DIR/cast.rs:84:5 - | -84 | 1i32 as usize; - | ^^^^^^^^^^^^^ - error: casting to the same type is unnecessary (`i32` -> `i32`) - --> $DIR/cast.rs:86:5 + --> $DIR/cast.rs:37:5 | -86 | 1i32 as i32; +37 | 1i32 as i32; | ^^^^^^^^^^^ | = note: `-D unnecessary-cast` implied by `-D warnings` error: casting to the same type is unnecessary (`f32` -> `f32`) - --> $DIR/cast.rs:87:5 + --> $DIR/cast.rs:38:5 | -87 | 1f32 as f32; +38 | 1f32 as f32; | ^^^^^^^^^^^ error: casting to the same type is unnecessary (`bool` -> `bool`) - --> $DIR/cast.rs:88:5 + --> $DIR/cast.rs:39:5 | -88 | false as bool; +39 | false as bool; | ^^^^^^^^^^^^^ diff --git a/tests/ui/cast_lossless_float.rs b/tests/ui/cast_lossless_float.rs new file mode 100644 index 000000000000..9e61059b630c --- /dev/null +++ b/tests/ui/cast_lossless_float.rs @@ -0,0 +1,15 @@ +#[warn(cast_lossless)] +#[allow(no_effect, unnecessary_operation)] +fn main() { + // Test cast_lossless with casts to floating-point types + 1i8 as f32; + 1i8 as f64; + 1u8 as f32; + 1u8 as f64; + 1i16 as f32; + 1i16 as f64; + 1u16 as f32; + 1u16 as f64; + 1i32 as f64; + 1u32 as f64; +} diff --git a/tests/ui/cast_lossless_float.stderr b/tests/ui/cast_lossless_float.stderr new file mode 100644 index 000000000000..781d9c897672 --- /dev/null +++ b/tests/ui/cast_lossless_float.stderr @@ -0,0 +1,62 @@ +error: casting i8 to f32 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:5:5 + | +5 | 1i8 as f32; + | ^^^^^^^^^^ help: try: `f32::from(1i8)` + | + = note: `-D cast-lossless` implied by `-D warnings` + +error: casting i8 to f64 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:6:5 + | +6 | 1i8 as f64; + | ^^^^^^^^^^ help: try: `f64::from(1i8)` + +error: casting u8 to f32 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:7:5 + | +7 | 1u8 as f32; + | ^^^^^^^^^^ help: try: `f32::from(1u8)` + +error: casting u8 to f64 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:8:5 + | +8 | 1u8 as f64; + | ^^^^^^^^^^ help: try: `f64::from(1u8)` + +error: casting i16 to f32 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:9:5 + | +9 | 1i16 as f32; + | ^^^^^^^^^^^ help: try: `f32::from(1i16)` + +error: casting i16 to f64 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:10:5 + | +10 | 1i16 as f64; + | ^^^^^^^^^^^ help: try: `f64::from(1i16)` + +error: casting u16 to f32 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:11:5 + | +11 | 1u16 as f32; + | ^^^^^^^^^^^ help: try: `f32::from(1u16)` + +error: casting u16 to f64 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:12:5 + | +12 | 1u16 as f64; + | ^^^^^^^^^^^ help: try: `f64::from(1u16)` + +error: casting i32 to f64 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:13:5 + | +13 | 1i32 as f64; + | ^^^^^^^^^^^ help: try: `f64::from(1i32)` + +error: casting u32 to f64 may become silently lossy if types change + --> $DIR/cast_lossless_float.rs:14:5 + | +14 | 1u32 as f64; + | ^^^^^^^^^^^ help: try: `f64::from(1u32)` + diff --git a/tests/ui/cast_lossless_integer.rs b/tests/ui/cast_lossless_integer.rs new file mode 100644 index 000000000000..5f89d057c332 --- /dev/null +++ b/tests/ui/cast_lossless_integer.rs @@ -0,0 +1,24 @@ + +#[warn(cast_lossless)] +#[allow(no_effect, unnecessary_operation)] +fn main() { + // Test 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; +} diff --git a/tests/ui/cast_lossless_integer.stderr b/tests/ui/cast_lossless_integer.stderr new file mode 100644 index 000000000000..fdd915979e48 --- /dev/null +++ b/tests/ui/cast_lossless_integer.stderr @@ -0,0 +1,110 @@ +error: casting i8 to i16 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:6:5 + | +6 | 1i8 as i16; + | ^^^^^^^^^^ help: try: `i16::from(1i8)` + | + = note: `-D cast-lossless` implied by `-D warnings` + +error: casting i8 to i32 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:7:5 + | +7 | 1i8 as i32; + | ^^^^^^^^^^ help: try: `i32::from(1i8)` + +error: casting i8 to i64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:8:5 + | +8 | 1i8 as i64; + | ^^^^^^^^^^ help: try: `i64::from(1i8)` + +error: casting u8 to i16 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:9:5 + | +9 | 1u8 as i16; + | ^^^^^^^^^^ help: try: `i16::from(1u8)` + +error: casting u8 to i32 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:10:5 + | +10 | 1u8 as i32; + | ^^^^^^^^^^ help: try: `i32::from(1u8)` + +error: casting u8 to i64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:11:5 + | +11 | 1u8 as i64; + | ^^^^^^^^^^ help: try: `i64::from(1u8)` + +error: casting u8 to u16 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:12:5 + | +12 | 1u8 as u16; + | ^^^^^^^^^^ help: try: `u16::from(1u8)` + +error: casting u8 to u32 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:13:5 + | +13 | 1u8 as u32; + | ^^^^^^^^^^ help: try: `u32::from(1u8)` + +error: casting u8 to u64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:14:5 + | +14 | 1u8 as u64; + | ^^^^^^^^^^ help: try: `u64::from(1u8)` + +error: casting i16 to i32 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:15:5 + | +15 | 1i16 as i32; + | ^^^^^^^^^^^ help: try: `i32::from(1i16)` + +error: casting i16 to i64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:16:5 + | +16 | 1i16 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1i16)` + +error: casting u16 to i32 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:17:5 + | +17 | 1u16 as i32; + | ^^^^^^^^^^^ help: try: `i32::from(1u16)` + +error: casting u16 to i64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:18:5 + | +18 | 1u16 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1u16)` + +error: casting u16 to u32 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:19:5 + | +19 | 1u16 as u32; + | ^^^^^^^^^^^ help: try: `u32::from(1u16)` + +error: casting u16 to u64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:20:5 + | +20 | 1u16 as u64; + | ^^^^^^^^^^^ help: try: `u64::from(1u16)` + +error: casting i32 to i64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:21:5 + | +21 | 1i32 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1i32)` + +error: casting u32 to i64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:22:5 + | +22 | 1u32 as i64; + | ^^^^^^^^^^^ help: try: `i64::from(1u32)` + +error: casting u32 to u64 may become silently lossy if types change + --> $DIR/cast_lossless_integer.rs:23:5 + | +23 | 1u32 as u64; + | ^^^^^^^^^^^ help: try: `u64::from(1u32)` + diff --git a/tests/ui/cast_size.rs b/tests/ui/cast_size.rs new file mode 100644 index 000000000000..d0bef860c709 --- /dev/null +++ b/tests/ui/cast_size.rs @@ -0,0 +1,23 @@ +#[warn(cast_precision_loss, cast_possible_truncation, cast_sign_loss, cast_possible_wrap, cast_lossless)] +#[allow(no_effect, unnecessary_operation)] +fn main() { + // Casting from *size + 1isize as i8; + 1isize as f64; + 1usize as f64; + 1isize as f32; + 1usize as f32; + 1isize as i32; + 1isize as u32; + 1usize as u32; + 1usize as i32; + // Casting to *size + 1i64 as isize; + 1i64 as usize; + 1u64 as isize; + 1u64 as usize; + 1u32 as isize; + 1u32 as usize; // Should not trigger any lint + 1i32 as isize; // Neither should this + 1i32 as usize; +} diff --git a/tests/ui/cast_size.stderr b/tests/ui/cast_size.stderr new file mode 100644 index 000000000000..a6aac1300a32 --- /dev/null +++ b/tests/ui/cast_size.stderr @@ -0,0 +1,122 @@ +error: casting isize to i8 may truncate the value + --> $DIR/cast_size.rs:5:5 + | +5 | 1isize as i8; + | ^^^^^^^^^^^^ + | + = note: `-D cast-possible-truncation` implied by `-D warnings` + +error: casting isize to f64 causes a loss of precision on targets with 64-bit wide pointers (isize is 64 bits wide, but f64's mantissa is only 52 bits wide) + --> $DIR/cast_size.rs:6:5 + | +6 | 1isize as f64; + | ^^^^^^^^^^^^^ + | + = note: `-D cast-precision-loss` implied by `-D warnings` + +error: casting usize to f64 causes a loss of precision on targets with 64-bit wide pointers (usize is 64 bits wide, but f64's mantissa is only 52 bits wide) + --> $DIR/cast_size.rs:7:5 + | +7 | 1usize as f64; + | ^^^^^^^^^^^^^ + +error: casting isize to f32 causes a loss of precision (isize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) + --> $DIR/cast_size.rs:8:5 + | +8 | 1isize as f32; + | ^^^^^^^^^^^^^ + +error: casting usize to f32 causes a loss of precision (usize is 32 or 64 bits wide, but f32's mantissa is only 23 bits wide) + --> $DIR/cast_size.rs:9:5 + | +9 | 1usize as f32; + | ^^^^^^^^^^^^^ + +error: casting isize to i32 may truncate the value on targets with 64-bit wide pointers + --> $DIR/cast_size.rs:10:5 + | +10 | 1isize as i32; + | ^^^^^^^^^^^^^ + +error: casting isize to u32 may lose the sign of the value + --> $DIR/cast_size.rs:11:5 + | +11 | 1isize as u32; + | ^^^^^^^^^^^^^ + | + = note: `-D cast-sign-loss` implied by `-D warnings` + +error: casting isize to u32 may truncate the value on targets with 64-bit wide pointers + --> $DIR/cast_size.rs:11:5 + | +11 | 1isize as u32; + | ^^^^^^^^^^^^^ + +error: casting usize to u32 may truncate the value on targets with 64-bit wide pointers + --> $DIR/cast_size.rs:12:5 + | +12 | 1usize as u32; + | ^^^^^^^^^^^^^ + +error: casting usize to i32 may truncate the value on targets with 64-bit wide pointers + --> $DIR/cast_size.rs:13:5 + | +13 | 1usize as i32; + | ^^^^^^^^^^^^^ + +error: casting usize to i32 may wrap around the value on targets with 32-bit wide pointers + --> $DIR/cast_size.rs:13:5 + | +13 | 1usize as i32; + | ^^^^^^^^^^^^^ + | + = note: `-D cast-possible-wrap` implied by `-D warnings` + +error: casting i64 to isize may truncate the value on targets with 32-bit wide pointers + --> $DIR/cast_size.rs:15:5 + | +15 | 1i64 as isize; + | ^^^^^^^^^^^^^ + +error: casting i64 to usize may lose the sign of the value + --> $DIR/cast_size.rs:16:5 + | +16 | 1i64 as usize; + | ^^^^^^^^^^^^^ + +error: casting i64 to usize may truncate the value on targets with 32-bit wide pointers + --> $DIR/cast_size.rs:16:5 + | +16 | 1i64 as usize; + | ^^^^^^^^^^^^^ + +error: casting u64 to isize may truncate the value on targets with 32-bit wide pointers + --> $DIR/cast_size.rs:17:5 + | +17 | 1u64 as isize; + | ^^^^^^^^^^^^^ + +error: casting u64 to isize may wrap around the value on targets with 64-bit wide pointers + --> $DIR/cast_size.rs:17:5 + | +17 | 1u64 as isize; + | ^^^^^^^^^^^^^ + +error: casting u64 to usize may truncate the value on targets with 32-bit wide pointers + --> $DIR/cast_size.rs:18:5 + | +18 | 1u64 as usize; + | ^^^^^^^^^^^^^ + +error: casting u32 to isize may wrap around the value on targets with 32-bit wide pointers + --> $DIR/cast_size.rs:19:5 + | +19 | 1u32 as isize; + | ^^^^^^^^^^^^^ + +error: casting i32 to usize may lose the sign of the value + --> $DIR/cast_size.rs:22:5 + | +22 | 1i32 as usize; + | ^^^^^^^^^^^^^ +