Closed
Description
This test fails to compile but should not:
fn take_mut_slice<'a>(v: &'a mut [int]) -> &'a int { &v[0] }
fn main() {
let mut x: ~[@mut [int]] = ~[@mut [3], @mut [4]];
let a = take_mut_slice(x[0]);
let b = take_mut_slice(x[1]);
*a + *b;
}
I get the following errors:
/home/nmatsakis/tmp/best-effort.rs:6:27: 6:30 error: cannot borrow `(*(*x)[])[]` as mutable more than once at at a time
/home/nmatsakis/tmp/best-effort.rs:6 let b = take_mut_slice(x[1]);
^~~
/home/nmatsakis/tmp/best-effort.rs:5:27: 5:30 note: second borrow of `(*(*x)[])[]` as mutable occurs here
/home/nmatsakis/tmp/best-effort.rs:5 let a = take_mut_slice(x[0]);
^~~