]> git.lizzy.rs Git - rust.git/blobdiff - src/test/compile-fail/borrowck-forbid-static-unsafe-interior.rs
auto merge of #15421 : catharsis/rust/doc-ffi-minor-fixes, r=alexcrichton
[rust.git] / src / test / compile-fail / borrowck-forbid-static-unsafe-interior.rs
index c790a040a91a4be332c9240b52994022f0509af3..1c7516ef7e2bfb2e3189c5e276f4f18d998d7a46 100644 (file)
@@ -32,9 +32,16 @@ enum UnsafeEnum<T> {
 static STATIC2: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
 static STATIC3: MyUnsafe<int> = MyUnsafe{value: STATIC2};
 
-static STATIC4: &'static Unsafe<int> = &'static STATIC2;
+static STATIC4: &'static Unsafe<int> = &STATIC2;
 //~^ ERROR borrow of immutable static items with unsafe interior is not allowed
 
+struct Wrap<T> {
+    value: T
+}
+
+static UNSAFE: Unsafe<int> = Unsafe{value: 1, marker1: marker::InvariantType};
+static WRAPPED_UNSAFE: Wrap<&'static Unsafe<int>> = Wrap { value: &UNSAFE };
+//~^ ERROR borrow of immutable static items with unsafe interior is not allowed
 
 fn main() {
     let a = &STATIC1;