-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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
Code
fn main() {
let x = &0u8;
let y: u32 = x as u32;
}
Current output
error[E0606]: casting `&u8` as `u32` is invalid
--> src/lib.rs:3:18
|
3 | let y: u32 = x as u32;
| -^^^^^^^
| |
| cannot cast `&u8` as `u32`
| help: dereference the expression: `*x`
Desired output
No response
Rationale and extra context
The x as u32
=> *x
transformation is trivial here, we should be able to do this with cargo fix --broken-code
imo. All remaining suggestions can already be applied so rustc can fix this code into let y: u32 = (*x).into();
Other cases
No response
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.