- Notifications
You must be signed in to change notification settings - Fork 14k
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.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code example:
#[derive(Debug)] struct Str { x: Option<i32>, } fn main() { let s = Str { x: None }; let sr = &s; let mut sm = sr.clone(); foo(&mut sm.x); } fn foo(s: &mut Option<i32>) { if s.is_none() { *s = Some(0); } println!("{:?}", s); } The Error is:
error: cannot borrow immutable field `sm.x` as mutable --> <anon>:10:14 |> 10 |> foo(&mut sm.x); |> ^^^^ This is misleading because the fix is to add a Clone impl for Str
Meta
rustc --version --verbose:
rustc 1.9.0-nightly (d5a91e6 2016-03-26)
binary: rustc
commit-hash: d5a91e6
commit-date: 2016-03-26
host: x86_64-apple-darwin
release: 1.9.0-nightly
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.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.