refactor check_for_cast

This commit is contained in:
Bastian Kauschke 2020-05-20 15:59:57 +02:00
parent 72a2d35f16
commit ecb593379c
6 changed files with 271 additions and 215 deletions

View file

@ -3,48 +3,88 @@ error[E0308]: mismatched types
|
LL | OhNo = 0_u8,
| ^^^^ expected `i8`, found `u8`
|
help: change the type of the numeric literal from `u8` to `i8`
|
LL | OhNo = 0_i8,
| ^^^^
error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:30:16
|
LL | OhNo = 0_i8,
| ^^^^ expected `u8`, found `i8`
|
help: change the type of the numeric literal from `i8` to `u8`
|
LL | OhNo = 0_u8,
| ^^^^
error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:43:16
|
LL | OhNo = 0_u16,
| ^^^^^ expected `i16`, found `u16`
|
help: change the type of the numeric literal from `u16` to `i16`
|
LL | OhNo = 0_i16,
| ^^^^^
error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:56:16
|
LL | OhNo = 0_i16,
| ^^^^^ expected `u16`, found `i16`
|
help: change the type of the numeric literal from `i16` to `u16`
|
LL | OhNo = 0_u16,
| ^^^^^
error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:69:16
|
LL | OhNo = 0_u32,
| ^^^^^ expected `i32`, found `u32`
|
help: change the type of the numeric literal from `u32` to `i32`
|
LL | OhNo = 0_i32,
| ^^^^^
error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:82:16
|
LL | OhNo = 0_i32,
| ^^^^^ expected `u32`, found `i32`
|
help: change the type of the numeric literal from `i32` to `u32`
|
LL | OhNo = 0_u32,
| ^^^^^
error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:95:16
|
LL | OhNo = 0_u64,
| ^^^^^ expected `i64`, found `u64`
|
help: change the type of the numeric literal from `u64` to `i64`
|
LL | OhNo = 0_i64,
| ^^^^^
error[E0308]: mismatched types
--> $DIR/discrim-ill-typed.rs:108:16
|
LL | OhNo = 0_i64,
| ^^^^^ expected `u64`, found `i64`
|
help: change the type of the numeric literal from `i64` to `u64`
|
LL | OhNo = 0_u64,
| ^^^^^
error: aborting due to 8 previous errors

View file

@ -3,12 +3,22 @@ error[E0308]: mismatched types
|
LL | A = 1i64,
| ^^^^ expected `isize`, found `i64`
|
help: change the type of the numeric literal from `i64` to `isize`
|
LL | A = 1isize,
| ^^^^^^
error[E0308]: mismatched types
--> $DIR/issue-8761.rs:5:9
|
LL | B = 2u8
| ^^^ expected `isize`, found `u8`
|
help: change the type of the numeric literal from `u8` to `isize`
|
LL | B = 2isize
| ^^^^^^
error: aborting due to 2 previous errors

View file

@ -3,6 +3,11 @@ error[E0308]: mismatched types
|
LL | const C: i32 = 1i8;
| ^^^ expected `i32`, found `i8`
|
help: change the type of the numeric literal from `i8` to `i32`
|
LL | const C: i32 = 1i32;
| ^^^^
error[E0308]: mismatched types
--> $DIR/const-scope.rs:2:15
@ -17,6 +22,11 @@ LL | let c: i32 = 1i8;
| --- ^^^ expected `i32`, found `i8`
| |
| expected due to this
|
help: change the type of the numeric literal from `i8` to `i32`
|
LL | let c: i32 = 1i32;
| ^^^^
error[E0308]: mismatched types
--> $DIR/const-scope.rs:6:17

View file

@ -22,6 +22,9 @@ fn main() {
let f = [0_usize; -1_isize];
//~^ ERROR mismatched types
//~| expected `usize`, found `isize`
let f = [0; 4u8];
//~^ ERROR mismatched types
//~| expected `usize`, found `u8`
struct G {
g: (),
}

View file

@ -29,7 +29,7 @@ LL | let e = [0; "foo"];
| ^^^^^ expected `usize`, found `&str`
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:28:17
--> $DIR/repeat_count.rs:31:17
|
LL | let g = [0; G { g: () }];
| ^^^^^^^^^^^ expected `usize`, found struct `main::G`
@ -46,7 +46,18 @@ error[E0308]: mismatched types
LL | let f = [0_usize; -1_isize];
| ^^^^^^^^ expected `usize`, found `isize`
error: aborting due to 8 previous errors
error[E0308]: mismatched types
--> $DIR/repeat_count.rs:25:17
|
LL | let f = [0; 4u8];
| ^^^ expected `usize`, found `u8`
|
help: change the type of the numeric literal from `u8` to `usize`
|
LL | let f = [0; 4usize];
| ^^^^^^
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0308, E0435.
For more information about an error, try `rustc --explain E0308`.