Closed
Description
fn main() {
let a = 1u8;
let _: i64 = a;
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/main.rs:3:18
|
3 | let _: i64 = a;
| --- ^ expected `i64`, found `u8`
| |
| expected due to this
|
help: you can convert an `u8` to `i64` and panic if the converted value wouldn't fit
|
3 | let _: i64 = a.try_into().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
I would’ve expected something like:
help: you can convert an `u8` to `i64`
|
3 | let _: i64 = a.into();
| ^^^^^^^^
Edit: What actually should happen is the same as currently already with _: u64
, i.e. it would look like
error[E0308]: mismatched types
--> src/main.rs:3:18
|
3 | let _: i64 = a;
| --- ^
| | |
| | expected `i64`, found `u8`
| | help: you can convert an `u8` to `i64`: `a.into()`
| expected due to this
@rustbot modify labels: A-diagnostics, T-compiler, D-papercut, C-enhancement, E-easy
This issue has been assigned to @samrat via this comment.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsCategory: An issue proposing an enhancement or a PR with one.Diagnostics: An error or lint that needs small tweaks.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the compiler team, which will review and decide on the PR/issue.