rust/src/test/ui/issues/issue-27282-move-ref-mut-into-guard.rs
2018-12-25 21:08:33 -07:00

19 lines
582 B
Rust

// Issue 27282: Example 1: This sidesteps the AST checks disallowing
// mutable borrows in match guards by hiding the mutable borrow in a
// guard behind a move (of the ref mut pattern id) within a closure.
//
// This example is not rejected by AST borrowck (and then reliably
// segfaults when executed).
#![feature(nll)]
fn main() {
match Some(&4) {
None => {},
ref mut foo
if { (|| { let bar = foo; bar.take() })(); false } => {},
//~^ ERROR cannot move out of borrowed content [E0507]
Some(s) => std::process::exit(*s),
}
}