]> git.lizzy.rs Git - rust.git/blob - src/test/ui/nll/issue-45157.rs
Auto merge of #105121 - oli-obk:simpler-cheaper-dump_mir, r=nnethercote
[rust.git] / src / test / ui / nll / issue-45157.rs
1 #![allow(unused)]
2
3
4 #[derive(Clone, Copy, Default)]
5 struct S {
6     a: u8,
7     b: u8,
8 }
9 #[derive(Clone, Copy, Default)]
10 struct Z {
11     c: u8,
12     d: u8,
13 }
14
15 union U {
16     s: S,
17     z: Z,
18 }
19
20 fn main() {
21     unsafe {
22         let mut u = U { s: Default::default() };
23
24         let mref = &mut u.s.a;
25         *mref = 22;
26
27         let nref = &u.z.c;
28         //~^ ERROR cannot borrow `u` (via `u.z.c`) as immutable because it is also borrowed as mutable (via `u.s.a`) [E0502]
29         println!("{} {}", mref, nref)
30     }
31 }