Closed
Description
When the borrow check fails in a loop, the error message can be quite confusing:
enum Nat {
S(~Nat),
Z
}
fn test(x: &mut Nat) {
let mut p = &mut *x;
loop {
match p {
&Z => break,
&S(~ref mut n) => p = &mut *n
}
}
}
The borrow checker informs me:
Test.rs|43 col 16 error| cannot borrow `*(*p)#0` as mutable more than once at a time
Test.rs|43 col 16 n| second borrow of `*(*p)#0` as mutable occurs here
This message is confusing, because the two occurrences have the same line number and column. In fact, the error message is right: the borrow check only fails because it is being performed in a loop. The error message should mention something like that to the effect.