From 0f4c40b229710fe087bef70ab79d3ede552a6bb7 Mon Sep 17 00:00:00 2001 From: Darren Tsung Date: Sat, 23 Dec 2017 10:15:11 -0800 Subject: [PATCH] Start regression tests for types.rs --- tests/ui/types.rs | 10 ++++++++++ tests/ui/types.stderr | 8 ++++++++ 2 files changed, 18 insertions(+) create mode 100644 tests/ui/types.rs create mode 100644 tests/ui/types.stderr 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` +