summaryrefslogtreecommitdiffstats
path: root/tests/ui/unboxed-closures/unboxed-closures-borrow-conflict.rs
blob: 835a1f598601c1540c8c6a1c88a8e79daeb77c19 (plain)
1
2
3
4
5
6
7
8
9
10
11
// Test that an unboxed closure that mutates a free variable will
// cause borrow conflicts.



fn main() {
    let mut x = 0;
    let f = || x += 1;
    let _y = x; //~ ERROR cannot use `x` because it was mutably borrowed
    f;
}