summaryrefslogtreecommitdiffstats
path: root/src/test/ui/regions/regions-return-ref-to-upvar-issue-17403.rs
blob: 86e759f088a549e7d4aa8f87577810e28b8bb1c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
// 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();
    }
}