]> git.lizzy.rs Git - rust.git/blob - src/test/ui/borrowck/move-from-union-field-issue-66500.rs
Rollup merge of #88090 - nbdd0121:inference, r=nikomatsakis
[rust.git] / src / test / ui / borrowck / move-from-union-field-issue-66500.rs
1 // Moving from a reference/raw pointer should be an error, even when they're
2 // the field of a union.
3
4 #![feature(untagged_unions)]
5
6 union Pointers {
7     a: &'static String,
8     b: &'static mut String,
9     c: *const String,
10     d: *mut String,
11 }
12
13 unsafe fn move_ref(u: Pointers) -> String {
14     *u.a
15     //~^ ERROR cannot move out of `*u.a`
16 }
17 unsafe fn move_ref_mut(u: Pointers) -> String {
18     *u.b
19     //~^ ERROR cannot move out of `*u.b`
20 }
21 unsafe fn move_ptr(u: Pointers) -> String {
22     *u.c
23     //~^ ERROR cannot move out of `*u.c`
24 }
25 unsafe fn move_ptr_mut(u: Pointers) -> String {
26     *u.d
27     //~^ ERROR cannot move out of `*u.d`
28 }
29
30 fn main() {}