-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
use std::cell::RefCell;
struct S {
node: E,
}
enum E {
Foo(uint),
Bar,
}
fn main() {
let x = RefCell::new(S { node: Foo(0) });
let mut b = x.borrow_mut();
match b.node {
Foo(ref mut n) => *n += 1,
_ => (),
}
}$ rustc -v
rustc 0.11.0 (49bc17bfdd7143909aede81652d7d624cecd8a70 2014-07-07 17:16:34 +0000)
$ rustc foo.rs
foo.rs:17:13: 17:22 error: cannot borrow immutable anonymous field as mutable
foo.rs:17 Foo(ref mut n) => *n += 1,
^~~~~~~~~
Changing to match b.deref_mut().node fixes the error.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.