rust/tests/ui/regions/regions-return-ref-to-upvar-issue-17403.rs
2023-01-11 09:32:08 +00:00

12 lines
273 B
Rust

// Test that closures cannot subvert aliasing restrictions
fn main() {
// Unboxed closure case
{
let mut x = 0;
let mut f = || &mut x; //~ ERROR captured variable cannot escape `FnMut` closure body
let x = f();
let y = f();
}
}