]> git.lizzy.rs Git - rust.git/blob - tests/ui/borrowck/move-from-union-field-issue-66500.rs
Rollup merge of #106726 - cmorin6:fix-comment-typos, r=Nilstrieb
[rust.git] / tests / 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 union Pointers {
5     a: &'static String,
6     b: &'static mut String,
7     c: *const String,
8     d: *mut String,
9 }
10
11 unsafe fn move_ref(u: Pointers) -> String {
12     *u.a
13     //~^ ERROR cannot move out of `*u.a`
14 }
15 unsafe fn move_ref_mut(u: Pointers) -> String {
16     *u.b
17     //~^ ERROR cannot move out of `*u.b`
18 }
19 unsafe fn move_ptr(u: Pointers) -> String {
20     *u.c
21     //~^ ERROR cannot move out of `*u.c`
22 }
23 unsafe fn move_ptr_mut(u: Pointers) -> String {
24     *u.d
25     //~^ ERROR cannot move out of `*u.d`
26 }
27
28 fn main() {}