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 // ignore-test currently ICEs when using NLL (#52416)
13 // We used to ICE when moving out of a `*mut T` or `*const T`.
17 static mut GLOBAL_MUT_T: T = T(0);
19 static GLOBAL_T: T = T(0);
21 fn imm_ref() -> &'static T {
25 fn mut_ref() -> &'static mut T {
26 unsafe { &mut GLOBAL_MUT_T }
29 fn mut_ptr() -> *mut T {
30 unsafe { 0 as *mut T }
33 fn const_ptr() -> *const T {
34 unsafe { 0 as *const T }
38 let a = unsafe { *mut_ref() };
39 //~^ ERROR cannot move out of borrowed content
41 let b = unsafe { *imm_ref() };
42 //~^ ERROR cannot move out of borrowed content
44 let c = unsafe { *mut_ptr() };
45 //~^ ERROR cannot move out of dereference of raw pointer
47 let d = unsafe { *const_ptr() };
48 //~^ ERROR cannot move out of dereference of raw pointer