diff --git a/tests/ui/types.rs b/tests/ui/types.rs new file mode 100644 index 00000000000..10d1c490ee6 --- /dev/null +++ b/tests/ui/types.rs @@ -0,0 +1,10 @@ +// should not warn on lossy casting in constant types +// because not supported yet +const C : i32 = 42; +const C_I64 : i64 = C as i64; + +fn main() { + // should suggest i64::from(c) + let c : i32 = 42; + let c_i64 : i64 = c as i64; +} diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr new file mode 100644 index 00000000000..a2f4ede5ca2 --- /dev/null +++ b/tests/ui/types.stderr @@ -0,0 +1,8 @@ +error: casting i32 to i64 may become silently lossy if types change + --> $DIR/types.rs:9:23 + | +9 | let c_i64 : i64 = c as i64; + | ^^^^^^^^ help: try: `i64::from(c)` + | + = note: `-D cast-lossless` implied by `-D warnings` +