Merge pull request #2296 from DarrenTsung/test_types

Start regression tests for types.rs
This commit is contained in:
Oliver Schneider 2018-01-12 14:55:39 +01:00 committed by GitHub
commit 7e21663f75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

10
tests/ui/types.rs Normal file
View File

@ -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;
}

8
tests/ui/types.stderr Normal file
View File

@ -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`