]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-closures-mut-of-mut.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-closures-mut-of-mut.rs
1 // Tests that two closures cannot simultaneously both have mutable
2 // access to the variable. Related to issue #6801.
3
4 fn get(x: &isize) -> isize {
5     *x
6 }
7
8 fn set(x: &mut isize) {
9     *x = 4;
10 }
11
12 fn a(x: &mut isize) {
13     let mut c1 = || set(&mut *x);
14     let mut c2 = || set(&mut *x);
15     //~^ ERROR two closures require unique access to `x` at the same time
16     c2(); c1();
17 }
18
19 fn main() {
20 }