1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 // We used to ICE when moving out of a `*mut T` or `*const T`.
15 static mut GLOBAL_MUT_T: T = T(0);
17 static GLOBAL_T: T = T(0);
19 fn imm_ref() -> &'static T {
23 fn mut_ref() -> &'static mut T {
24 unsafe { &mut GLOBAL_MUT_T }
27 fn mut_ptr() -> *mut T {
28 unsafe { 0 as *mut T }
31 fn const_ptr() -> *const T {
32 unsafe { 0 as *const T }
36 let a = unsafe { *mut_ref() };
37 //~^ ERROR cannot move out of borrowed content
39 let b = unsafe { *imm_ref() };
40 //~^ ERROR cannot move out of borrowed content
42 let c = unsafe { *mut_ptr() };
43 //~^ ERROR cannot move out of dereference of raw pointer
45 let d = unsafe { *const_ptr() };
46 //~^ ERROR cannot move out of dereference of raw pointer