Skip to content

Commit 5c30dc8

Browse files
committed
rust-lang#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.
1 parent 173315e commit 5c30dc8

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/test/ui/borrowck/issue-41962.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ pub fn main(){
1515

1616
loop {
1717
if let Some(thing) = maybe {
18-
//~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]
18+
}
19+
//~^^ ERROR use of partially moved value: `maybe` (Ast) [E0382]
1920
//~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]
2021
//~| ERROR use of moved value: `maybe` (Mir) [E0382]
2122
//~| ERROR use of moved value: `maybe` (Mir) [E0382]
2223
//~| ERROR use of moved value: `maybe.0` (Mir) [E0382]
23-
}
24+
//~| ERROR borrow of moved value: `maybe` (Mir) [E0382]
2425
}
2526
}

src/test/ui/borrowck/issue-41962.stderr

+13-6
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,23 @@ LL | if let Some(thing) = maybe {
2323
| ^ ----- value moved here
2424
| _________|
2525
| |
26-
LL | | //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382]
27-
LL | | //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382]
28-
LL | | //~| ERROR use of moved value: `maybe` (Mir) [E0382]
29-
LL | | //~| ERROR use of moved value: `maybe` (Mir) [E0382]
30-
LL | | //~| ERROR use of moved value: `maybe.0` (Mir) [E0382]
3126
LL | | }
3227
| |_________^ value used here after move
3328
|
3429
= note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait
3530

31+
error[E0382]: borrow of moved value: `maybe` (Mir)
32+
--> $DIR/issue-41962.rs:17:9
33+
|
34+
LL | if let Some(thing) = maybe {
35+
| ^ ----- value moved here
36+
| _________|
37+
| |
38+
LL | | }
39+
| |_________^ value borrowed here after move
40+
|
41+
= note: move occurs because `maybe` has type `std::option::Option<std::vec::Vec<bool>>`, which does not implement the `Copy` trait
42+
3643
error[E0382]: use of moved value: `maybe` (Mir)
3744
--> $DIR/issue-41962.rs:17:16
3845
|
@@ -52,6 +59,6 @@ LL | if let Some(thing) = maybe {
5259
|
5360
= note: move occurs because `maybe.0` has type `std::vec::Vec<bool>`, which does not implement the `Copy` trait
5461

55-
error: aborting due to 5 previous errors
62+
error: aborting due to 6 previous errors
5663

5764
For more information about this error, try `rustc --explain E0382`.

0 commit comments

Comments
 (0)