Skip to content

Commit 7e21663

Browse files
authored
Merge pull request #2296 from DarrenTsung/test_types
Start regression tests for types.rs
2 parents c66eaee + 0f4c40b commit 7e21663

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

tests/ui/types.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// should not warn on lossy casting in constant types
2+
// because not supported yet
3+
const C : i32 = 42;
4+
const C_I64 : i64 = C as i64;
5+
6+
fn main() {
7+
// should suggest i64::from(c)
8+
let c : i32 = 42;
9+
let c_i64 : i64 = c as i64;
10+
}

tests/ui/types.stderr

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: casting i32 to i64 may become silently lossy if types change
2+
--> $DIR/types.rs:9:23
3+
|
4+
9 | let c_i64 : i64 = c as i64;
5+
| ^^^^^^^^ help: try: `i64::from(c)`
6+
|
7+
= note: `-D cast-lossless` implied by `-D warnings`
8+

0 commit comments

Comments
 (0)