]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-in-first-arm.rs
Rollup merge of #106692 - eggyal:mv-binary_heap.rs-binary_heap/mod.rs, r=Mark-Simulacrum
[rust.git] / tests / ui / rfc-0107-bind-by-move-pattern-guards / rfc-reject-double-move-in-first-arm.rs
1 #![feature(if_let_guard)]
2
3 struct A { a: Box<i32> }
4
5 fn if_guard(n: i32) {
6     let x = A { a: Box::new(n) };
7     let _y = match x {
8         A { a: v } if { drop(v); true } => v,
9         //~^ ERROR cannot move out of `v` in pattern guard
10         _ => Box::new(0),
11     };
12 }
13
14 fn if_let_guard(n: i32) {
15     let x = A { a: Box::new(n) };
16     let _y = match x {
17         A { a: v } if let Some(()) = { drop(v); Some(()) } => v,
18         //~^ ERROR cannot move out of `v` in pattern guard
19         _ => Box::new(0),
20     };
21 }
22
23 fn main() {
24     if_guard(107);
25     if_let_guard(107);
26 }