1 // Test that we have enough false edges to avoid exposing the exact matching
2 // algorithm in borrow checking.
4 #![feature(nll, bind_by_move_pattern_guards)]
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,
16 fn guard_may_be_skipped(y: i32) {
18 // Even though x *is* always initialized, we don't want to have borrowck
19 // results be based on whether patterns are exhaustive.
21 _ if { x = 2; true } => 1,
23 x; //~ ERROR use of possibly uninitialized variable: `x`
30 fn guard_may_be_taken(y: bool) {
31 let x = String::new();
32 // Even though x *is* never moved before the use, we don't want to have
33 // borrowck results be based on whether patterns are disjoint.
35 false if { drop(x); true } => 1,
37 x; //~ ERROR use of moved value: `x`
44 fn all_previous_tests_may_be_done(y: &mut (bool, bool)) {
46 // We don't actually test y.1 to select the second arm, but we don't want
47 // borrowck results to be based on the order we match patterns.
49 (false, true) => 1, //~ ERROR cannot use `y.1` because it was mutably borrowed