Closed
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