mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 15:11:30 +00:00
Merge pull request #2296 from DarrenTsung/test_types
Start regression tests for types.rs
This commit is contained in:
commit
7e21663f75
2 changed files with 18 additions and 0 deletions
10
tests/ui/types.rs
Normal file
10
tests/ui/types.rs
Normal 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
8
tests/ui/types.stderr
Normal 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`
|
||||
|
Loading…
Reference in a new issue