summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/borrowck-closures-mut-of-imm.rs
blob: d7e187a2b39580ba2927e5deb330d1473d57b2da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// Tests that two closures cannot simultaneously have mutable
// and immutable access to the variable. Issue #6801.

fn set(x: &mut isize) {
    *x = 4;
}

fn a(x: &isize) {
    let mut c1 = || set(&mut *x);
    //~^ ERROR cannot borrow
    let mut c2 = || set(&mut *x);
    //~^ ERROR cannot borrow
    //~| ERROR two closures require unique access to `x` at the same time
    c2(); c1();
}

fn main() {
}