diff options
Diffstat (limited to 'tests/ui/borrowck/borrowck-closures-mut-of-mut.rs')
-rw-r--r-- | tests/ui/borrowck/borrowck-closures-mut-of-mut.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ui/borrowck/borrowck-closures-mut-of-mut.rs b/tests/ui/borrowck/borrowck-closures-mut-of-mut.rs new file mode 100644 index 000000000..50c6f2c58 --- /dev/null +++ b/tests/ui/borrowck/borrowck-closures-mut-of-mut.rs @@ -0,0 +1,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() { +} |