-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed
Closed
Copy link
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.
Description
The following code:
struct NotCopy;
fn main() {
let mut a = NotCopy;
loop {
|| {
&mut a;
a;
};
}
}
produces the following error:
error[E0382]: use of moved value: `a`
--> src/lib.rs:6:9
|
4 | let mut a = NotCopy;
| ----- move occurs because `a` has type `NotCopy`, which does not implement the `Copy` trait
5 | loop {
6 | || {
| ^^ value moved into closure here, in previous iteration of loop
7 | &mut a;
| - use occurs due to use in closure
However, the &mut a;
statement is not responsible for the move - it's the a;
statement below it which causes the move.
Meta
rustc --version --verbose
:
rustc 1.47.0-nightly (de521cbb3 2020-08-21)
binary: rustc
commit-hash: de521cbb303c08febd9fa3755caccd4f3e491ea3
commit-date: 2020-08-21
host: x86_64-unknown-linux-gnu
release: 1.47.0-nightly
LLVM version: 10.0
Metadata
Metadata
Assignees
Labels
A-borrow-checkerArea: The borrow checkerArea: The borrow checkerA-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.