1 // Test that we have enough false edges to avoid exposing the exact matching
2 // algorithm in borrow checking.
4 #![feature(if_let_guard)]
6 fn guard_always_precedes_arm(y: i32) {
8 // x should always be initialized, as the only way to reach the arm is
11 0 | 2 if { x = 2; true } => x,
17 0 | 2 if let Some(()) = { x = 2; Some(()) } => x,
22 fn guard_may_be_skipped(y: i32) {
24 // Even though x *is* always initialized, we don't want to have borrowck
25 // results be based on whether patterns are exhaustive.
27 _ if { x = 2; true } => 1,
37 _ if let Some(()) = { x = 2; Some(()) } => 1,
46 fn guard_may_be_taken(y: bool) {
47 let x = String::new();
48 // Even though x *is* never moved before the use, we don't want to have
49 // borrowck results be based on whether patterns are disjoint.
51 false if { drop(x); true } => 1,
53 x; //~ ERROR use of moved value: `x`
59 let x = String::new();
61 false if let Some(()) = { drop(x); Some(()) } => 1,
63 x; //~ ERROR use of moved value: `x`