1 // Copyright 2014 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 // Verify that it is not possible to take the address of
12 // static items with usnafe interior.
14 use std::kinds::marker;
22 fn forbidden(&self) {}
27 VariantUnsafe(Unsafe<T>)
30 static STATIC1: UnsafeEnum<int> = VariantSafe;
32 static STATIC2: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
33 static STATIC3: MyUnsafe<int> = MyUnsafe{value: STATIC2};
35 static STATIC4: &'static Unsafe<int> = &'static STATIC2;
36 //~^ ERROR borrow of immutable static items with unsafe interior is not allowed
42 static UNSAFE: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
43 static WRAPPED_UNSAFE: Wrap<&'static Unsafe<int>> = Wrap { value: &UNSAFE };
44 //~^ ERROR borrow of immutable static items with unsafe interior is not allowed
48 //~^ ERROR borrow of immutable static items with unsafe interior is not allowed
51 //~^ ERROR borrow of immutable static items with unsafe interior is not allowed