-
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
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
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.