]> git.proxmox.com Git - rustc.git/blame - src/test/ui/borrowck/borrowck-assign-to-subfield.rs
New upstream version 1.52.0+dfsg1
[rustc.git] / src / test / ui / borrowck / borrowck-assign-to-subfield.rs
CommitLineData
b7449926 1// run-pass
c34b1796
AL
2// pretty-expanded FIXME #23616
3
1a4d82fc 4pub fn main() {
223e47cc 5 struct A {
c34b1796 6 a: isize,
223e47cc 7 w: B,
223e47cc
LB
8 }
9 struct B {
c34b1796 10 a: isize
223e47cc
LB
11 }
12 let mut p = A {
13 a: 1,
14 w: B {a: 1},
223e47cc
LB
15 };
16
17 // even though `x` is not declared as a mutable field,
18 // `p` as a whole is mutable, so it can be modified.
19 p.a = 2;
20
21 // this is true for an interior field too
22 p.w.a = 2;
223e47cc 23}