diff --git a/tests/ui/types.fixed b/tests/ui/types.fixed new file mode 100644 index 00000000000..a71a9ec8124 --- /dev/null +++ b/tests/ui/types.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +#![allow(dead_code, unused_variables)] + +// 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 = i64::from(c); +} diff --git a/tests/ui/types.rs b/tests/ui/types.rs index 45846d6eef8..6f48080cedd 100644 --- a/tests/ui/types.rs +++ b/tests/ui/types.rs @@ -1,3 +1,7 @@ +// run-rustfix + +#![allow(dead_code, unused_variables)] + // should not warn on lossy casting in constant types // because not supported yet const C: i32 = 42; diff --git a/tests/ui/types.stderr b/tests/ui/types.stderr index 97cce7add03..f85e27a24ec 100644 --- a/tests/ui/types.stderr +++ b/tests/ui/types.stderr @@ -1,5 +1,5 @@ error: casting i32 to i64 may become silently lossy if types change - --> $DIR/types.rs:9:22 + --> $DIR/types.rs:13:22 | LL | let c_i64: i64 = c as i64; | ^^^^^^^^ help: try: `i64::from(c)`