]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
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. | |
4 | // | |
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. | |
10 | ||
c34b1796 AL |
11 | // pretty-expanded FIXME #23616 |
12 | ||
13 | #![feature(core)] | |
ea8adc8c | 14 | #![feature(const_unsafe_cell_new)] |
c34b1796 | 15 | |
1a4d82fc JJ |
16 | use std::marker; |
17 | use std::cell::UnsafeCell; | |
18 | ||
19 | struct MyUnsafePack<T>(UnsafeCell<T>); | |
20 | ||
21 | unsafe impl<T: Send> Sync for MyUnsafePack<T> {} | |
22 | ||
23 | struct MyUnsafe<T> { | |
24 | value: MyUnsafePack<T> | |
25 | } | |
26 | ||
27 | impl<T> MyUnsafe<T> { | |
28 | fn forbidden(&self) {} | |
29 | } | |
30 | ||
31 | unsafe impl<T: Send> Sync for MyUnsafe<T> {} | |
32 | ||
33 | enum UnsafeEnum<T> { | |
34 | VariantSafe, | |
35 | VariantUnsafe(UnsafeCell<T>) | |
36 | } | |
37 | ||
38 | unsafe impl<T: Send> Sync for UnsafeEnum<T> {} | |
39 | ||
c34b1796 | 40 | static STATIC1: UnsafeEnum<isize> = UnsafeEnum::VariantSafe; |
1a4d82fc | 41 | |
62682a34 SL |
42 | static STATIC2: MyUnsafePack<isize> = MyUnsafePack(UnsafeCell::new(1)); |
43 | const CONST: MyUnsafePack<isize> = MyUnsafePack(UnsafeCell::new(1)); | |
c34b1796 | 44 | static STATIC3: MyUnsafe<isize> = MyUnsafe{value: CONST}; |
1a4d82fc | 45 | |
c34b1796 | 46 | static STATIC4: &'static MyUnsafePack<isize> = &STATIC2; |
1a4d82fc JJ |
47 | |
48 | struct Wrap<T> { | |
49 | value: T | |
50 | } | |
51 | ||
52 | unsafe impl<T: Send> Sync for Wrap<T> {} | |
53 | ||
62682a34 | 54 | static UNSAFE: MyUnsafePack<isize> = MyUnsafePack(UnsafeCell::new(2)); |
c34b1796 | 55 | static WRAPPED_UNSAFE: Wrap<&'static MyUnsafePack<isize>> = Wrap { value: &UNSAFE }; |
1a4d82fc JJ |
56 | |
57 | fn main() { | |
58 | let a = &STATIC1; | |
59 | ||
60 | STATIC3.forbidden() | |
61 | } |