]>
Commit | Line | Data |
---|---|---|
85aaf69f SL |
1 | // We used to ICE when moving out of a `*mut T` or `*const T`. |
2 | ||
3 | struct T(u8); | |
4 | ||
5 | static mut GLOBAL_MUT_T: T = T(0); | |
6 | ||
7 | static GLOBAL_T: T = T(0); | |
8 | ||
9 | fn imm_ref() -> &'static T { | |
10 | unsafe { &GLOBAL_T } | |
11 | } | |
12 | ||
13 | fn mut_ref() -> &'static mut T { | |
14 | unsafe { &mut GLOBAL_MUT_T } | |
15 | } | |
16 | ||
17 | fn mut_ptr() -> *mut T { | |
dc9dc135 | 18 | unsafe { core::ptr::null_mut() } |
85aaf69f SL |
19 | } |
20 | ||
21 | fn const_ptr() -> *const T { | |
dc9dc135 | 22 | unsafe { core::ptr::null() } |
85aaf69f SL |
23 | } |
24 | ||
25 | pub fn main() { | |
26 | let a = unsafe { *mut_ref() }; | |
dc9dc135 | 27 | //~^ ERROR cannot move out of a mutable reference |
85aaf69f SL |
28 | |
29 | let b = unsafe { *imm_ref() }; | |
dc9dc135 | 30 | //~^ ERROR cannot move out of a shared reference |
85aaf69f SL |
31 | |
32 | let c = unsafe { *mut_ptr() }; | |
dc9dc135 | 33 | //~^ ERROR cannot move out of a raw pointer |
85aaf69f SL |
34 | |
35 | let d = unsafe { *const_ptr() }; | |
dc9dc135 | 36 | //~^ ERROR cannot move out of a raw pointer |
85aaf69f | 37 | } |