Skip to content

E0606 could be auto-applicable in some cases #106903

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthiaskrgr opened this issue Jan 15, 2023 · 1 comment · Fixed by #106927
Closed

E0606 could be auto-applicable in some cases #106903

matthiaskrgr opened this issue Jan 15, 2023 · 1 comment · Fixed by #106927
Assignees
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Jan 15, 2023

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

@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 15, 2023
@Ezrashaw
Copy link
Contributor

@rustbot claim

This just involves making the suggestion be MachineApplicable right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants