fixup! Note numeric literals that can never fit in an expected type
This commit is contained in:
parent
2b936bb5a2
commit
f0d36891b6
@ -19,4 +19,69 @@ fn main() {
|
||||
//~^ ERROR mismatched types
|
||||
x_u8 > -1_isize;
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
x_usize > -1_i128;
|
||||
//~^ ERROR mismatched types
|
||||
x_u128 > -1_i128;
|
||||
//~^ ERROR mismatched types
|
||||
x_u64 > -1_i128;
|
||||
//~^ ERROR mismatched types
|
||||
x_u32 > -1_i128;
|
||||
//~^ ERROR mismatched types
|
||||
x_u16 > -1_i128;
|
||||
//~^ ERROR mismatched types
|
||||
x_u8 > -1_i128;
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
x_usize > -1_i64;
|
||||
//~^ ERROR mismatched types
|
||||
x_u128 > -1_i64;
|
||||
//~^ ERROR mismatched types
|
||||
x_u64 > -1_i64;
|
||||
//~^ ERROR mismatched types
|
||||
x_u32 > -1_i64;
|
||||
//~^ ERROR mismatched types
|
||||
x_u16 > -1_i64;
|
||||
//~^ ERROR mismatched types
|
||||
x_u8 > -1_i64;
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
x_usize > -1_i32;
|
||||
//~^ ERROR mismatched types
|
||||
x_u128 > -1_i32;
|
||||
//~^ ERROR mismatched types
|
||||
x_u64 > -1_i32;
|
||||
//~^ ERROR mismatched types
|
||||
x_u32 > -1_i32;
|
||||
//~^ ERROR mismatched types
|
||||
x_u16 > -1_i32;
|
||||
//~^ ERROR mismatched types
|
||||
x_u8 > -1_i32;
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
x_usize > -1_i16;
|
||||
//~^ ERROR mismatched types
|
||||
x_u128 > -1_i16;
|
||||
//~^ ERROR mismatched types
|
||||
x_u64 > -1_i16;
|
||||
//~^ ERROR mismatched types
|
||||
x_u32 > -1_i16;
|
||||
//~^ ERROR mismatched types
|
||||
x_u16 > -1_i16;
|
||||
//~^ ERROR mismatched types
|
||||
x_u8 > -1_i16;
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
x_usize > -1_i8;
|
||||
//~^ ERROR mismatched types
|
||||
x_u128 > -1_i8;
|
||||
//~^ ERROR mismatched types
|
||||
x_u64 > -1_i8;
|
||||
//~^ ERROR mismatched types
|
||||
x_u32 > -1_i8;
|
||||
//~^ ERROR mismatched types
|
||||
x_u16 > -1_i8;
|
||||
//~^ ERROR mismatched types
|
||||
x_u8 > -1_i8;
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
@ -69,6 +69,356 @@ help: you can convert `x_u8` from `u8` to `isize`, matching the type of `-1_isiz
|
||||
LL | isize::from(x_u8) > -1_isize;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:23:15
|
||||
|
|
||||
LL | x_usize > -1_i128;
|
||||
| ^^^^^^^ expected `usize`, found `i128`
|
||||
|
|
||||
note: `-1_i128` cannot fit into type `usize`
|
||||
--> $DIR/numeric-cast-no-fix.rs:23:15
|
||||
|
|
||||
LL | x_usize > -1_i128;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:25:14
|
||||
|
|
||||
LL | x_u128 > -1_i128;
|
||||
| ^^^^^^^ expected `u128`, found `i128`
|
||||
|
|
||||
note: `-1_i128` cannot fit into type `u128`
|
||||
--> $DIR/numeric-cast-no-fix.rs:25:14
|
||||
|
|
||||
LL | x_u128 > -1_i128;
|
||||
| ^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:27:13
|
||||
|
|
||||
LL | x_u64 > -1_i128;
|
||||
| ^^^^^^^ expected `u64`, found `i128`
|
||||
|
|
||||
help: you can convert `x_u64` from `u64` to `i128`, matching the type of `-1_i128`
|
||||
|
|
||||
LL | i128::from(x_u64) > -1_i128;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:29:13
|
||||
|
|
||||
LL | x_u32 > -1_i128;
|
||||
| ^^^^^^^ expected `u32`, found `i128`
|
||||
|
|
||||
help: you can convert `x_u32` from `u32` to `i128`, matching the type of `-1_i128`
|
||||
|
|
||||
LL | i128::from(x_u32) > -1_i128;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:31:13
|
||||
|
|
||||
LL | x_u16 > -1_i128;
|
||||
| ^^^^^^^ expected `u16`, found `i128`
|
||||
|
|
||||
help: you can convert `x_u16` from `u16` to `i128`, matching the type of `-1_i128`
|
||||
|
|
||||
LL | i128::from(x_u16) > -1_i128;
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:33:12
|
||||
|
|
||||
LL | x_u8 > -1_i128;
|
||||
| ^^^^^^^ expected `u8`, found `i128`
|
||||
|
|
||||
help: you can convert `x_u8` from `u8` to `i128`, matching the type of `-1_i128`
|
||||
|
|
||||
LL | i128::from(x_u8) > -1_i128;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:36:15
|
||||
|
|
||||
LL | x_usize > -1_i64;
|
||||
| ^^^^^^ expected `usize`, found `i64`
|
||||
|
|
||||
note: `-1_i64` cannot fit into type `usize`
|
||||
--> $DIR/numeric-cast-no-fix.rs:36:15
|
||||
|
|
||||
LL | x_usize > -1_i64;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:38:14
|
||||
|
|
||||
LL | x_u128 > -1_i64;
|
||||
| ^^^^^^ expected `u128`, found `i64`
|
||||
|
|
||||
note: `-1_i64` cannot fit into type `u128`
|
||||
--> $DIR/numeric-cast-no-fix.rs:38:14
|
||||
|
|
||||
LL | x_u128 > -1_i64;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:40:13
|
||||
|
|
||||
LL | x_u64 > -1_i64;
|
||||
| ^^^^^^ expected `u64`, found `i64`
|
||||
|
|
||||
note: `-1_i64` cannot fit into type `u64`
|
||||
--> $DIR/numeric-cast-no-fix.rs:40:13
|
||||
|
|
||||
LL | x_u64 > -1_i64;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:42:13
|
||||
|
|
||||
LL | x_u32 > -1_i64;
|
||||
| ^^^^^^ expected `u32`, found `i64`
|
||||
|
|
||||
help: you can convert `x_u32` from `u32` to `i64`, matching the type of `-1_i64`
|
||||
|
|
||||
LL | i64::from(x_u32) > -1_i64;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:44:13
|
||||
|
|
||||
LL | x_u16 > -1_i64;
|
||||
| ^^^^^^ expected `u16`, found `i64`
|
||||
|
|
||||
help: you can convert `x_u16` from `u16` to `i64`, matching the type of `-1_i64`
|
||||
|
|
||||
LL | i64::from(x_u16) > -1_i64;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:46:12
|
||||
|
|
||||
LL | x_u8 > -1_i64;
|
||||
| ^^^^^^ expected `u8`, found `i64`
|
||||
|
|
||||
help: you can convert `x_u8` from `u8` to `i64`, matching the type of `-1_i64`
|
||||
|
|
||||
LL | i64::from(x_u8) > -1_i64;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:49:15
|
||||
|
|
||||
LL | x_usize > -1_i32;
|
||||
| ^^^^^^ expected `usize`, found `i32`
|
||||
|
|
||||
note: `-1_i32` cannot fit into type `usize`
|
||||
--> $DIR/numeric-cast-no-fix.rs:49:15
|
||||
|
|
||||
LL | x_usize > -1_i32;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:51:14
|
||||
|
|
||||
LL | x_u128 > -1_i32;
|
||||
| ^^^^^^ expected `u128`, found `i32`
|
||||
|
|
||||
note: `-1_i32` cannot fit into type `u128`
|
||||
--> $DIR/numeric-cast-no-fix.rs:51:14
|
||||
|
|
||||
LL | x_u128 > -1_i32;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:53:13
|
||||
|
|
||||
LL | x_u64 > -1_i32;
|
||||
| ^^^^^^ expected `u64`, found `i32`
|
||||
|
|
||||
note: `-1_i32` cannot fit into type `u64`
|
||||
--> $DIR/numeric-cast-no-fix.rs:53:13
|
||||
|
|
||||
LL | x_u64 > -1_i32;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:55:13
|
||||
|
|
||||
LL | x_u32 > -1_i32;
|
||||
| ^^^^^^ expected `u32`, found `i32`
|
||||
|
|
||||
note: `-1_i32` cannot fit into type `u32`
|
||||
--> $DIR/numeric-cast-no-fix.rs:55:13
|
||||
|
|
||||
LL | x_u32 > -1_i32;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:57:13
|
||||
|
|
||||
LL | x_u16 > -1_i32;
|
||||
| ^^^^^^ expected `u16`, found `i32`
|
||||
|
|
||||
help: you can convert `x_u16` from `u16` to `i32`, matching the type of `-1_i32`
|
||||
|
|
||||
LL | i32::from(x_u16) > -1_i32;
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:59:12
|
||||
|
|
||||
LL | x_u8 > -1_i32;
|
||||
| ^^^^^^ expected `u8`, found `i32`
|
||||
|
|
||||
help: you can convert `x_u8` from `u8` to `i32`, matching the type of `-1_i32`
|
||||
|
|
||||
LL | i32::from(x_u8) > -1_i32;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:62:15
|
||||
|
|
||||
LL | x_usize > -1_i16;
|
||||
| ^^^^^^ expected `usize`, found `i16`
|
||||
|
|
||||
note: `-1_i16` cannot fit into type `usize`
|
||||
--> $DIR/numeric-cast-no-fix.rs:62:15
|
||||
|
|
||||
LL | x_usize > -1_i16;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:64:14
|
||||
|
|
||||
LL | x_u128 > -1_i16;
|
||||
| ^^^^^^ expected `u128`, found `i16`
|
||||
|
|
||||
note: `-1_i16` cannot fit into type `u128`
|
||||
--> $DIR/numeric-cast-no-fix.rs:64:14
|
||||
|
|
||||
LL | x_u128 > -1_i16;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:66:13
|
||||
|
|
||||
LL | x_u64 > -1_i16;
|
||||
| ^^^^^^ expected `u64`, found `i16`
|
||||
|
|
||||
note: `-1_i16` cannot fit into type `u64`
|
||||
--> $DIR/numeric-cast-no-fix.rs:66:13
|
||||
|
|
||||
LL | x_u64 > -1_i16;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:68:13
|
||||
|
|
||||
LL | x_u32 > -1_i16;
|
||||
| ^^^^^^ expected `u32`, found `i16`
|
||||
|
|
||||
note: `-1_i16` cannot fit into type `u32`
|
||||
--> $DIR/numeric-cast-no-fix.rs:68:13
|
||||
|
|
||||
LL | x_u32 > -1_i16;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:70:13
|
||||
|
|
||||
LL | x_u16 > -1_i16;
|
||||
| ^^^^^^ expected `u16`, found `i16`
|
||||
|
|
||||
note: `-1_i16` cannot fit into type `u16`
|
||||
--> $DIR/numeric-cast-no-fix.rs:70:13
|
||||
|
|
||||
LL | x_u16 > -1_i16;
|
||||
| ^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:72:12
|
||||
|
|
||||
LL | x_u8 > -1_i16;
|
||||
| ^^^^^^ expected `u8`, found `i16`
|
||||
|
|
||||
help: you can convert `x_u8` from `u8` to `i16`, matching the type of `-1_i16`
|
||||
|
|
||||
LL | i16::from(x_u8) > -1_i16;
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:75:15
|
||||
|
|
||||
LL | x_usize > -1_i8;
|
||||
| ^^^^^ expected `usize`, found `i8`
|
||||
|
|
||||
note: `-1_i8` cannot fit into type `usize`
|
||||
--> $DIR/numeric-cast-no-fix.rs:75:15
|
||||
|
|
||||
LL | x_usize > -1_i8;
|
||||
| ^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:77:14
|
||||
|
|
||||
LL | x_u128 > -1_i8;
|
||||
| ^^^^^ expected `u128`, found `i8`
|
||||
|
|
||||
note: `-1_i8` cannot fit into type `u128`
|
||||
--> $DIR/numeric-cast-no-fix.rs:77:14
|
||||
|
|
||||
LL | x_u128 > -1_i8;
|
||||
| ^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:79:13
|
||||
|
|
||||
LL | x_u64 > -1_i8;
|
||||
| ^^^^^ expected `u64`, found `i8`
|
||||
|
|
||||
note: `-1_i8` cannot fit into type `u64`
|
||||
--> $DIR/numeric-cast-no-fix.rs:79:13
|
||||
|
|
||||
LL | x_u64 > -1_i8;
|
||||
| ^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:81:13
|
||||
|
|
||||
LL | x_u32 > -1_i8;
|
||||
| ^^^^^ expected `u32`, found `i8`
|
||||
|
|
||||
note: `-1_i8` cannot fit into type `u32`
|
||||
--> $DIR/numeric-cast-no-fix.rs:81:13
|
||||
|
|
||||
LL | x_u32 > -1_i8;
|
||||
| ^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:83:13
|
||||
|
|
||||
LL | x_u16 > -1_i8;
|
||||
| ^^^^^ expected `u16`, found `i8`
|
||||
|
|
||||
note: `-1_i8` cannot fit into type `u16`
|
||||
--> $DIR/numeric-cast-no-fix.rs:83:13
|
||||
|
|
||||
LL | x_u16 > -1_i8;
|
||||
| ^^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/numeric-cast-no-fix.rs:85:12
|
||||
|
|
||||
LL | x_u8 > -1_i8;
|
||||
| ^^^^^ expected `u8`, found `i8`
|
||||
|
|
||||
note: `-1_i8` cannot fit into type `u8`
|
||||
--> $DIR/numeric-cast-no-fix.rs:85:12
|
||||
|
|
||||
LL | x_u8 > -1_i8;
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to 36 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user