Given
fn foo() -> i32 {
let s: i32 = 3usize;
s
}
we present
error[E0308]: mismatched types
--> src/lib.rs:2:18
|
2 | let s: i32 = 3usize;
| ^^^^^^ expected i32, found usize
help: change the type of the numeric literal from `usize` to `i32`
|
2 | let s: i32 = 3i32;
| ^^^^
We would ideally also point at the assignment's type in the same way we do for type mismatches against a return type:
error[E0308]: mismatched types
--> src/lib.rs:2:18
|
2 | let s: i32 = 3usize;
| --- ^^^^^^ expected i32, found usize
| |
| expected due to this
help: change the type of the numeric literal from `usize` to `i32`
|
2 | let s: i32 = 3i32;
| ^^^^
Given
we present
We would ideally also point at the assignment's type in the same way we do for type mismatches against a return type: