]> git.lizzy.rs Git - rust.git/blob - tests/ui/rfc-0107-bind-by-move-pattern-guards/rfc-reject-double-move-across-arms.rs
Rollup merge of #106570 - Xaeroxe:div-duration-tests, r=JohnTitor
[rust.git] / tests / ui / rfc-0107-bind-by-move-pattern-guards / rfc-reject-double-move-across-arms.rs
1 #![feature(if_let_guard)]
2
3 enum VecWrapper { A(Vec<i32>) }
4
5 fn if_guard(x: VecWrapper) -> usize {
6     match x {
7         VecWrapper::A(v) if { drop(v); false } => 1,
8         //~^ ERROR cannot move out of `v` in pattern guard
9         VecWrapper::A(v) => v.len()
10     }
11 }
12
13 fn if_let_guard(x: VecWrapper) -> usize {
14     match x {
15         VecWrapper::A(v) if let Some(()) = { drop(v); None } => 1,
16         //~^ ERROR cannot move out of `v` in pattern guard
17         VecWrapper::A(v) => v.len()
18     }
19 }
20
21 fn main() {
22     if_guard(VecWrapper::A(vec![107]));
23     if_let_guard(VecWrapper::A(vec![107]));
24 }