]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/borrowck-assign-to-subfield.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / ui / borrowck / borrowck-assign-to-subfield.rs
1 // run-pass
2 // pretty-expanded FIXME #23616
3
4 pub fn main() {
5     struct A {
6         a: isize,
7         w: B,
8     }
9     struct B {
10         a: isize
11     }
12     let mut p = A {
13         a: 1,
14         w: B {a: 1},
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;
23 }