Closed

Description
struct Foo {
pub v: Vec<String>
}
fn main() {
let f = Foo { v: Vec::new() };
f.v.push("cat".to_string());
}
The above code gives this compile error:
<anon>:8:5: 8:8 error: cannot borrow immutable field `f.v` as mutable
<anon>:8 f.v.push("cat".to_string());
^~~
From my perspective, this implies that the field somehow needs to be marked as mutable, when in fact the user error is that the struct is immutable.
I believe the error message could be improved by saying something like cannot borrow field
vof immutable struct
f as mutable
.
#18150 is "related".