Closed
Description
I try this code: (Playground)
fn main() {
let a: u16;
let b: u16 = 42;
let c: usize = 5;
a = c + b * 5;
}
I expect to see this happen: No invalid suggestion for usize::from(a) = c + b*5
.
Instead, I got this errors:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/main.rs:6:13
|
6 | a = c + b * 5;
| ^^^^^ expected `usize`, found `u16`
error[E0308]: mismatched types
--> src/main.rs:6:9
|
6 | a = c + b * 5;
| ^^^^^^^^^ expected `u16`, found `usize`
|
help: you can convert `a` from `u16` to `usize`, matching the type of `c + b * 5`
|
6 | usize::from(a) = c + b * 5;
| ^^^^^^^^^^^^^^
error[E0277]: cannot add `u16` to `usize`
--> src/main.rs:6:11
|
6 | a = c + b * 5;
| ^ no implementation for `usize + u16`
|
= help: the trait `Add<u16>` is not implemented for `usize`
@rustbot label D-invalid-suggestion T-compiler