summaryrefslogtreecommitdiffstats
path: root/tests/ui/borrowck/move-from-union-field-issue-66500.rs
blob: 0bd2147f46331000feb45428c2451e58f59b3a98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Moving from a reference/raw pointer should be an error, even when they're
// the field of a union.

union Pointers {
    a: &'static String,
    b: &'static mut String,
    c: *const String,
    d: *mut String,
}

unsafe fn move_ref(u: Pointers) -> String {
    *u.a
    //~^ ERROR cannot move out of `*u.a`
}
unsafe fn move_ref_mut(u: Pointers) -> String {
    *u.b
    //~^ ERROR cannot move out of `*u.b`
}
unsafe fn move_ptr(u: Pointers) -> String {
    *u.c
    //~^ ERROR cannot move out of `*u.c`
}
unsafe fn move_ptr_mut(u: Pointers) -> String {
    *u.d
    //~^ ERROR cannot move out of `*u.d`
}

fn main() {}