2018-09-04 10:05:53 +00:00
|
|
|
//@ run-pass
|
2015-03-22 20:13:15 +00:00
|
|
|
//@ pretty-expanded FIXME #23616
|
|
|
|
|
2014-01-03 23:30:54 +00:00
|
|
|
pub fn main() {
|
2013-02-21 23:19:40 +00:00
|
|
|
struct A {
|
2015-03-26 00:06:52 +00:00
|
|
|
a: isize,
|
2013-02-21 23:19:40 +00:00
|
|
|
w: B,
|
|
|
|
}
|
|
|
|
struct B {
|
2015-03-26 00:06:52 +00:00
|
|
|
a: isize
|
2013-02-21 23:19:40 +00:00
|
|
|
}
|
|
|
|
let mut p = A {
|
|
|
|
a: 1,
|
|
|
|
w: B {a: 1},
|
|
|
|
};
|
2012-05-11 02:58:23 +00:00
|
|
|
|
|
|
|
// even though `x` is not declared as a mutable field,
|
|
|
|
// `p` as a whole is mutable, so it can be modified.
|
|
|
|
p.a = 2;
|
|
|
|
|
|
|
|
// this is true for an interior field too
|
|
|
|
p.w.a = 2;
|
2013-02-14 19:47:00 +00:00
|
|
|
}
|