]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-27282-move-ref-mut-into-guard.rs
Rollup merge of #105216 - GuillaumeGomez:rm-unused-gui-test, r=notriddle
[rust.git] / src / test / ui / nll / 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 fn main() {
6     match Some(&4) {
7         None => {},
8         ref mut foo
9             if { (|| { let bar = foo; bar.take() })(); false } => {},
10         //~^ ERROR cannot move out of `foo` in pattern guard [E0507]
11         Some(s) => std::process::exit(*s),
12     }
13 }