Closed
Description
I tried the following code (playground link):
fn main() {
let mut a: u8 = 0;
let b: u32 = 0;
a = b;
}
I expected the compiler to recommend using b.try_into().unwrap()
to convert it into a u8
. This seems to have been the case in version 1.37.0. Instead, it produces the following error message on stable, beta, and nightly:
error[E0308]: mismatched types
--> src/main.rs:4:9
|
4 | a = b;
| ^ expected `u8`, found `u32`
|
help: you can convert `a` from `u8` to `u32`, matching the type of `b`
|
4 | u32::from(a) = b;
| ^^^^^^^^^^^^
The suggestion is incorrect, as the return value of a function call is not assignable.