"assigning... prohibited due to outstanding loan" could be clearer #2969
Closed
Description
fn main()
{
let mut x = [mut 1, 2, 4];
let v : &int = &x[2];
x[2] = 6;
assert *v == 6;
}
gives me
/Users/jruderman/Desktop/a.rs:5:3: 5:6 error: assigning to mutable vec content prohibited due to outstanding loan
/Users/jruderman/Desktop/a.rs:5 x[2] = 6;
^~~
/Users/jruderman/Desktop/a.rs:4:19: 4:22 note: loan of mutable vec content granted here
/Users/jruderman/Desktop/a.rs:4 let v : &int = &x[2];
^~~
I think the error message should emphasize that it is an immutable loan. So it's clear that if you were to change it to a mutable loan, it's okay.