]> git.proxmox.com Git - rustc.git/blob - src/test/ui/closures/2229_closure_analysis/diagnostics/union.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / closures / 2229_closure_analysis / diagnostics / union.rs
1 // edition:2021
2
3 // Test that we point to the correct location that results a union being captured.
4 // Union is special because it can't be disjointly captured.
5
6 union A {
7 y: u32,
8 x: (),
9 }
10
11 fn main() {
12 let mut a = A { y: 1 };
13 let mut c = || {
14 //~^ borrow of `a.y` occurs here
15 let _ = unsafe { &a.y };
16 let _ = &mut a;
17 //~^ borrow occurs due to use in closure
18 let _ = unsafe { &mut a.y };
19 };
20 a.y = 1;
21 //~^ cannot assign to `a.y` because it is borrowed [E0506]
22 //~| assignment to borrowed `a.y` occurs here
23 c();
24 //~^ borrow later used here
25 }