2015-02-10 14:01:31 +00:00
|
|
|
// We used to ICE when moving out of a `*mut T` or `*const T`.
|
|
|
|
|
|
|
|
struct T(u8);
|
|
|
|
|
|
|
|
static mut GLOBAL_MUT_T: T = T(0);
|
|
|
|
|
|
|
|
static GLOBAL_T: T = T(0);
|
|
|
|
|
|
|
|
fn imm_ref() -> &'static T {
|
|
|
|
unsafe { &GLOBAL_T }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mut_ref() -> &'static mut T {
|
|
|
|
unsafe { &mut GLOBAL_MUT_T }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn mut_ptr() -> *mut T {
|
2019-06-17 10:52:37 +00:00
|
|
|
unsafe { core::ptr::null_mut() }
|
2015-02-10 14:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn const_ptr() -> *const T {
|
2019-06-17 10:52:37 +00:00
|
|
|
unsafe { core::ptr::null() }
|
2015-02-10 14:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
let a = unsafe { *mut_ref() };
|
2019-05-05 11:02:32 +00:00
|
|
|
//~^ ERROR cannot move out of a mutable reference
|
2015-02-10 14:01:31 +00:00
|
|
|
|
|
|
|
let b = unsafe { *imm_ref() };
|
2019-05-05 11:02:32 +00:00
|
|
|
//~^ ERROR cannot move out of a shared reference
|
2015-02-10 14:01:31 +00:00
|
|
|
|
|
|
|
let c = unsafe { *mut_ptr() };
|
2019-05-05 11:02:32 +00:00
|
|
|
//~^ ERROR cannot move out of a raw pointer
|
2015-02-10 14:01:31 +00:00
|
|
|
|
|
|
|
let d = unsafe { *const_ptr() };
|
2019-05-05 11:02:32 +00:00
|
|
|
//~^ ERROR cannot move out of a raw pointer
|
2015-02-10 14:01:31 +00:00
|
|
|
}
|