Closed
Description
UPDATE: This was fixed by #47167 but still needs a regression test to be added.
fn main() {
let mut i = [1,2,3];
i[i[0]] = 0; // Works
i[i[0] - 1] = 0; // Is rejected
}
I had expect the - 1
not to make any difference, but the borrow checker complains with the following error:
<anon>:4:7: 4:11 error: cannot use `i[..]` because it was mutably borrowed
<anon>:4 i[i[0] - 1] = 0;
^~~~
<anon>:4:5: 4:6 note: borrow of `i` occurs here
<anon>:4 i[i[0] - 1] = 0;
Metadata
Metadata
Assignees
Labels
Area: Non-lexical lifetimes (NLL)Area: The borrow checkerCategory: This is a bug.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.Medium priorityRelevant to the language team, which will review and decide on the PR/issue.Bugs fixed, but only when NLL is enabled.