Closed
Description
Code
fn main() {
let x: u8 = (4i32);
}
Current output
error[E0308]: mismatched types
--> src/main.rs:2:17
|
2 | let x: u8 = (4i32);
| -- ^^^^^^ expected `u8`, found `i32`
| |
| expected due to this
|
help: change the type of the numeric literal from `i32` to `u8`
|
2 | let x: u8 = (4i32)u8;
| ++
Desired output
error[E0308]: mismatched types
--> src/main.rs:2:17
|
2 | let x: u8 = (4i32);
| -- ^^^^^^ expected `u8`, found `i32`
| |
| expected due to this
|
help: change the type of the numeric literal from `i32` to `u8`
|
2 | let x: u8 = 4u8;
|
Rationale and extra context
No response
Other cases
Rust Version
1.87.0-nightly
(2025-03-11 6650252439d4e03368b3)
Anything else?
No response