-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.Diagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.