about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorFelix S. Klock II <pnkfelix@pnkfx.org>2015-07-17 16:12:35 +0200
committerFelix S. Klock II <pnkfelix@pnkfx.org>2015-10-06 14:16:49 +0200
commitd778e57bf61b2284f33d28486f2ac63faa0422cf (patch)
treec6b40557ab5e5f1d9de0724c3926bfd0abb5a28e /src/libcollections
parent9868df2fd5d9364a1a1d8b22847c7b442a77a88b (diff)
downloadrust-d778e57bf61b2284f33d28486f2ac63faa0422cf.tar.gz
rust-d778e57bf61b2284f33d28486f2ac63faa0422cf.zip
Add RFC 1238's `unsafe_destructor_blind_to_params` (UGEH) where needed.
I needed it in `RawVec`, `Vec`, and `TypedArena` for `rustc` to
bootstrap; but of course that alone was not sufficient for `make
check`.

Later I added `unsafe_destructor_blind_to_params` to collections, in
particular `LinkedList` and `RawTable` (the backing representation for
`HashMap` and `HashSet`), to get the regression tests exercising
cyclic structure from PR #27185 building.

----

Note that the feature is `dropck_parametricity` (which is not the same
as the attribute's name). We will almost certainly vary our strategy
here in the future, so it makes some sense to have a not-as-ugly name
for the feature gate. (The attribute name was deliberately selected to
be ugly looking.)
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/btree/node.rs3
-rw-r--r--src/libcollections/lib.rs6
-rw-r--r--src/libcollections/linked_list.rs1
-rw-r--r--src/libcollections/vec.rs1
-rw-r--r--src/libcollections/vec_deque.rs1
5 files changed, 12 insertions, 0 deletions
diff --git a/src/libcollections/btree/node.rs b/src/libcollections/btree/node.rs
index 5ac8a698e98..bde0d0e6b5f 100644
--- a/src/libcollections/btree/node.rs
+++ b/src/libcollections/btree/node.rs
@@ -275,12 +275,14 @@ impl<T> DoubleEndedIterator for RawItems<T> {
 }
 
 impl<T> Drop for RawItems<T> {
+    #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
         for _ in self {}
     }
 }
 
 impl<K, V> Drop for Node<K, V> {
+    #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
         if self.keys.is_null() ||
             (unsafe { self.keys.get() as *const K as usize == mem::POST_DROP_USIZE })
@@ -1419,6 +1421,7 @@ impl<K, V> TraversalImpl for MoveTraversalImpl<K, V> {
 }
 
 impl<K, V> Drop for MoveTraversalImpl<K, V> {
+    #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
         // We need to cleanup the stored values manually, as the RawItems destructor would run
         // after our deallocation.
diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs
index 03ee8ba31b1..4292c200fbe 100644
--- a/src/libcollections/lib.rs
+++ b/src/libcollections/lib.rs
@@ -32,6 +32,11 @@
 #![allow(trivial_casts)]
 #![cfg_attr(test, allow(deprecated))] // rand
 
+// SNAP 1af31d4
+#![allow(unused_features)]
+// SNAP 1af31d4
+#![allow(unused_attributes)]
+
 #![feature(alloc)]
 #![feature(box_patterns)]
 #![feature(box_syntax)]
@@ -59,6 +64,7 @@
 #![feature(unboxed_closures)]
 #![feature(unicode)]
 #![feature(unique)]
+#![feature(dropck_parametricity)]
 #![feature(unsafe_no_drop_flag, filling_drop)]
 #![feature(decode_utf16)]
 #![feature(utf8_error)]
diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs
index 891e8b7b2c9..fca7d3b26fc 100644
--- a/src/libcollections/linked_list.rs
+++ b/src/libcollections/linked_list.rs
@@ -655,6 +655,7 @@ impl<T> LinkedList<T> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> Drop for LinkedList<T> {
+    #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
         // Dissolve the linked_list in a loop.
         // Just dropping the list_head can lead to stack exhaustion
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index bcde523307c..d374c0959f3 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1385,6 +1385,7 @@ impl<T: Ord> Ord for Vec<T> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> Drop for Vec<T> {
+    #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
         // NOTE: this is currently abusing the fact that ZSTs can't impl Drop.
         // Or rather, that impl'ing Drop makes them not zero-sized. This is
diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs
index f7efe9a38df..d438c27a96f 100644
--- a/src/libcollections/vec_deque.rs
+++ b/src/libcollections/vec_deque.rs
@@ -64,6 +64,7 @@ impl<T: Clone> Clone for VecDeque<T> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> Drop for VecDeque<T> {
+    #[unsafe_destructor_blind_to_params]
     fn drop(&mut self) {
         self.clear();
         // RawVec handles deallocation