Closed
Description
fn returns_usize() -> usize {
let x = 0u8;
x
}
error[E0308]: mismatched types
--> src/lib.rs:3:5
|
1 | fn returns_usize() -> usize {
| ----- expected `usize` because of return type
2 | let x = 0u8;
3 | x
| ^ expected `usize`, found `u8`
|
help: you can convert an `u8` to `usize` and panic if the converted value wouldn't fit
|
3 | x.try_into().unwrap()
|
It would be better to suggest x.into()
instead, which is shorter, cannot fail, and doesn't require importing a trait.
This issue has been assigned to @ryr3 via this comment.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: An issue proposing an enhancement or a PR with one.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.