3 // Here is arielb1's basic example from rust-lang/rust#27282
4 // that AST borrowck is flummoxed by:
6 fn should_reject_destructive_mutate_in_guard() {
10 (|| { let bar = foo; bar.take() })();
11 //~^ ERROR cannot move out of `foo` in pattern guard [E0507]
13 Some(s) => std::process::exit(*s),
17 // Here below is a case that needs to keep working: we only use the
18 // binding via immutable-borrow in the guard, and we mutate in the arm
20 fn allow_mutate_in_arm_body() {
23 ref mut foo if foo.is_some() && false => { foo.take(); () }
24 Some(s) => std::process::exit(*s),
28 // Here below is a case that needs to keep working: we only use the
29 // binding via immutable-borrow in the guard, and we move into the arm
31 fn allow_move_into_arm_body() {
34 mut foo if foo.is_some() && false => { foo.take(); () }
35 Some(s) => std::process::exit(*s),
40 should_reject_destructive_mutate_in_guard();
41 allow_mutate_in_arm_body();
42 allow_move_into_arm_body();