about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-04-21 14:02:37 +0000
committerbors <bors@rust-lang.org>2017-04-21 14:02:37 +0000
commit5695c3e9435a5872e23a6bb61c1ea0b3ada83eef (patch)
tree8496a09a530afa6c2b2a5ead08b1d315abbbf590 /src/libcore
parent4ed95009d8d5d50c4f7aee35ad89c30a2258ffa9 (diff)
parent89bd3f39cadbbe0b361303ddbda2796ea7f39bb9 (diff)
Auto merge of #41349 - eddyb:ty-contents, r=nikomatsakis
rustc: replace TypeContents with two independent properties (is_freeze / needs_drop).

`InteriorUnsafe` / `interior_unsafe` was replaced with a private lang-item `Freeze` auto trait in libcore.

`OwnsDtor` / `needs_drop` was replaced with a specialized traversal that *doesn't* avoid caching results in case of a cycle, as the only cycles left can only occur in erroneous "types with infinite sizes", references and raw pointers not having destructors. Also, `Copy` is now checked at every step of the recursion.

r? @nikomatsakis
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/marker.rs17
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 {}