Skip to content

Error message mentions "x.0" (x is Option) #99470

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
safinaskar opened this issue Jul 19, 2022 · 1 comment · Fixed by #99629
Closed

Error message mentions "x.0" (x is Option) #99470

safinaskar opened this issue Jul 19, 2022 · 1 comment · Fixed by #99629
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

@safinaskar
Copy link
Contributor

safinaskar commented Jul 19, 2022

Given the following code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=449ac104599c2bb219212dd16afa49d1

fn main() {
    let x: &Option<Box<i32>> = &Some(Box::new(0));

    match x {
        &Some(_y) => (),
        &None => (),
    }
}

The current output is:

Compiling playground v0.0.1 (/playground)
error[[E0507]](https://doc.rust-lang.org/stable/error-index.html#E0507): cannot move out of `x.0` which is behind a shared reference
 --> src/main.rs:4:7
  |
4 | match x {
  |       ^
5 |     &Some(_y) => (),
  |     ---------
  |     |     |
  |     |     data moved here
  |     |     move occurs because `_y` has type `Box<i32>`, which does not implement the `Copy` trait
  |     help: consider removing the `&`: `Some(_y)`

The output mentions x.0, but x is Option, so x.0 is nonsense

@safinaskar safinaskar 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 Jul 19, 2022
@obeis
Copy link
Contributor

obeis commented Jul 19, 2022

@rustbot claim

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