2018-09-04 05:05:53 -05:00
|
|
|
// run-pass
|
2015-03-22 15:13:15 -05:00
|
|
|
// pretty-expanded FIXME #23616
|
|
|
|
|
2014-01-03 17:30:54 -06:00
|
|
|
pub fn main() {
|
2013-02-21 17:19:40 -06:00
|
|
|
struct A {
|
2015-03-25 19:06:52 -05:00
|
|
|
a: isize,
|
2013-02-21 17:19:40 -06:00
|
|
|
w: B,
|
|
|
|
}
|
|
|
|
struct B {
|
2015-03-25 19:06:52 -05:00
|
|
|
a: isize
|
2013-02-21 17:19:40 -06:00
|
|
|
}
|
|
|
|
let mut p = A {
|
|
|
|
a: 1,
|
|
|
|
w: B {a: 1},
|
|
|
|
};
|
2012-05-10 21:58:23 -05: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 13:47:00 -06:00
|
|
|
}
|