diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-04-17 21:18:56 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-04-20 14:39:31 +0300 |
| commit | 6563374ed2e518ea5fec2b7411dc4331772c46d2 (patch) | |
| tree | 6211971da9ad119e25d1b2c2e13960c65611a29d /src/libcore | |
| parent | 3f5c311dc1dcb5bfe65d6eecd0dfda04d77c7594 (diff) | |
| download | rust-6563374ed2e518ea5fec2b7411dc4331772c46d2.tar.gz rust-6563374ed2e518ea5fec2b7411dc4331772c46d2.zip | |
rustc: replace interior_unsafe with a Freeze trait.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/marker.rs | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs index 393c01b0105..c0aa650a1e8 100644 --- a/src/libcore/marker.rs +++ b/src/libcore/marker.rs @@ -16,6 +16,7 @@ #![stable(feature = "rust1", since = "1.0.0")] +use cell::UnsafeCell; use cmp; use hash::Hash; use hash::Hasher; @@ -553,3 +554,19 @@ mod impls { #[stable(feature = "rust1", since = "1.0.0")] unsafe impl<'a, T: Send + ?Sized> Send for &'a mut T {} } + +/// Compiler-internal trait used to determine whether a type contains +/// any `UnsafeCell` internally, but not through an indirection. +/// This affects, for example, whether a `static` of that type is +/// placed in read-only static memory or writable static memory. +#[cfg_attr(not(stage0), lang = "freeze")] +unsafe trait Freeze {} + +unsafe impl Freeze for .. {} + +impl<T: ?Sized> !Freeze for UnsafeCell<T> {} +unsafe impl<T: ?Sized> Freeze for PhantomData<T> {} +unsafe impl<T: ?Sized> Freeze for *const T {} +unsafe impl<T: ?Sized> Freeze for *mut T {} +unsafe impl<'a, T: ?Sized> Freeze for &'a T {} +unsafe impl<'a, T: ?Sized> Freeze for &'a mut T {} |
