1 // Issue #62007: assigning over a const-index projection of an array
2 // (in this case, `list[I] = n;`) should in theory be able to kill all borrows
3 // of `list[0]`, so that `list[0]` could be borrowed on the next
4 // iteration through the loop.
6 // Currently the compiler does not allow this. We may want to consider
7 // loosening that restriction in the future. (However, doing so would
8 // at *least* require T-lang team approval, and probably an RFC; e.g.
9 // such loosening might make complicate the user's mental mode; it
10 // also would make code more brittle in the face of refactorings that
11 // replace constants with variables.
17 next: Option<Box<List<T>>>,
20 fn to_refs<T>(mut list: [&mut List<T>; 2]) -> Vec<&mut T> {
21 let mut result = vec![];
23 result.push(&mut list[0].value); //~ ERROR cannot borrow `list[_].value` as mutable
24 if let Some(n) = list[0].next.as_mut() { //~ ERROR cannot borrow `list[_].next` as mutable