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