Skip to content

Start regression tests for types.rs #2296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/ui/types.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 8 additions & 0 deletions tests/ui/types.stderr
Original file line number Diff line number Diff line change
@@ -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`