From 5c30dc85c23d23482148f5eb0485320bc1abc2a3 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 9 May 2018 17:17:58 +0200 Subject: [PATCH] rust-lang/rust#41962 has a new error with my new code. Incorporate that into my code. In particular, I am adding an implicit injected borrow on the pattern matches, and when we go around the loop, the compiler is reporting that this injected borrow is conflicting with the move of the original value when the match succeeds. --- src/test/ui/borrowck/issue-41962.rs | 5 +++-- src/test/ui/borrowck/issue-41962.stderr | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/test/ui/borrowck/issue-41962.rs b/src/test/ui/borrowck/issue-41962.rs index f7c33691ad07..29481dbe5221 100644 --- a/src/test/ui/borrowck/issue-41962.rs +++ b/src/test/ui/borrowck/issue-41962.rs @@ -15,11 +15,12 @@ pub fn main(){ loop { if let Some(thing) = maybe { - //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382] + } + //~^^ ERROR use of partially moved value: `maybe` (Ast) [E0382] //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] //~| ERROR use of moved value: `maybe` (Mir) [E0382] //~| ERROR use of moved value: `maybe` (Mir) [E0382] //~| ERROR use of moved value: `maybe.0` (Mir) [E0382] - } + //~| ERROR borrow of moved value: `maybe` (Mir) [E0382] } } diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr index 39525d787b1f..e6eb3739d8c6 100644 --- a/src/test/ui/borrowck/issue-41962.stderr +++ b/src/test/ui/borrowck/issue-41962.stderr @@ -23,16 +23,23 @@ LL | if let Some(thing) = maybe { | ^ ----- value moved here | _________| | | -LL | | //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382] -LL | | //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] -LL | | //~| ERROR use of moved value: `maybe` (Mir) [E0382] -LL | | //~| ERROR use of moved value: `maybe` (Mir) [E0382] -LL | | //~| ERROR use of moved value: `maybe.0` (Mir) [E0382] LL | | } | |_________^ value used here after move | = note: move occurs because `maybe` has type `std::option::Option>`, which does not implement the `Copy` trait +error[E0382]: borrow of moved value: `maybe` (Mir) + --> $DIR/issue-41962.rs:17:9 + | +LL | if let Some(thing) = maybe { + | ^ ----- value moved here + | _________| + | | +LL | | } + | |_________^ value borrowed here after move + | + = note: move occurs because `maybe` has type `std::option::Option>`, which does not implement the `Copy` trait + error[E0382]: use of moved value: `maybe` (Mir) --> $DIR/issue-41962.rs:17:16 | @@ -52,6 +59,6 @@ LL | if let Some(thing) = maybe { | = note: move occurs because `maybe.0` has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 5 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0382`.