-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
struct S { x: i32 }
let s = S { x: 42 };
s.x += 1; //~ERROR cannot assign to immutable field
It occurred to me that this might be confusing to newcomers because fields don't have mutability in Rust, instead we have inherited mutability. So maybe it should say "cannot assign to field of immutable struct" or "cannot modify field due to immutable binding" or something.
cf #18150
bombless, hanna-kruppe, tagstar, eddyb, Eh2406 and 6 more
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.