]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs
Update tests for changes to cannot move errors
[rust.git] / src / test / ui / issues / issue-27282-move-ref-mut-into-guard.rs
1 // Issue 27282: Example 1: This sidesteps the AST checks disallowing
2 // mutable borrows in match guards by hiding the mutable borrow in a
3 // guard behind a move (of the ref mut pattern id) within a closure.
4 //
5 // This example is not rejected by AST borrowck (and then reliably
6 // segfaults when executed).
7
8 #![feature(nll)]
9
10 fn main() {
11     match Some(&4) {
12         None => {},
13         ref mut foo
14             if { (|| { let bar = foo; bar.take() })(); false } => {},
15         //~^ ERROR cannot move out of `foo` in pattern guard [E0507]
16         Some(s) => std::process::exit(*s),
17     }
18 }