blob: 50c6f2c585ed9d83e016cd5b6eeafe9b81632a18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
// Tests that two closures cannot simultaneously both have mutable
// access to the variable. Related to issue #6801.
fn get(x: &isize) -> isize {
*x
}
fn set(x: &mut isize) {
*x = 4;
}
fn a(x: &mut isize) {
let mut c1 = || set(&mut *x);
let mut c2 = || set(&mut *x);
//~^ ERROR two closures require unique access to `x` at the same time
c2(); c1();
}
fn main() {
}
|