rust/tests/ui/regions/regions-return-ref-to-upvar-issue-17403.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

12 lines
273 B
Rust
Raw Normal View History

2014-10-08 02:08:30 -05:00
// Test that closures cannot subvert aliasing restrictions
fn main() {
// Unboxed closure case
{
let mut x = 0;
2020-05-20 12:58:41 -05:00
let mut f = || &mut x; //~ ERROR captured variable cannot escape `FnMut` closure body
2014-10-08 02:08:30 -05:00
let x = f();
let y = f();
}
}