diff options
| author | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-07-17 16:12:35 +0200 |
|---|---|---|
| committer | Felix S. Klock II <pnkfelix@pnkfx.org> | 2015-10-06 14:16:49 +0200 |
| commit | d778e57bf61b2284f33d28486f2ac63faa0422cf (patch) | |
| tree | c6b40557ab5e5f1d9de0724c3926bfd0abb5a28e /src | |
| parent | 9868df2fd5d9364a1a1d8b22847c7b442a77a88b (diff) | |
| download | rust-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')
| -rw-r--r-- | src/liballoc/lib.rs | 5 | ||||
| -rw-r--r-- | src/liballoc/raw_vec.rs | 1 | ||||
| -rw-r--r-- | src/libarena/lib.rs | 7 | ||||
| -rw-r--r-- | src/libcollections/btree/node.rs | 3 | ||||
| -rw-r--r-- | src/libcollections/lib.rs | 6 | ||||
| -rw-r--r-- | src/libcollections/linked_list.rs | 1 | ||||
| -rw-r--r-- | src/libcollections/vec.rs | 1 | ||||
| -rw-r--r-- | src/libcollections/vec_deque.rs | 1 | ||||
| -rw-r--r-- | src/libstd/collections/hash/table.rs | 1 | ||||
| -rw-r--r-- | src/libstd/lib.rs | 6 | ||||
| -rw-r--r-- | src/libsyntax/feature_gate.rs | 8 | ||||
| -rw-r--r-- | src/test/run-pass/issue-24805-dropck-itemless.rs | 7 |
12 files changed, 42 insertions, 5 deletions
diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 98c729aaba4..8ecc78a231e 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -94,6 +94,11 @@ #![feature(unboxed_closures)] #![feature(unique)] #![feature(unsafe_no_drop_flag, filling_drop)] +// SNAP 1af31d4 +#![allow(unused_features)] +// SNAP 1af31d4 +#![allow(unused_attributes)] +#![feature(dropck_parametricity)] #![feature(unsize)] #![feature(core_slice_ext)] #![feature(core_str_ext)] diff --git a/src/liballoc/raw_vec.rs b/src/liballoc/raw_vec.rs index dd2db6fab08..49d37698154 100644 --- a/src/liballoc/raw_vec.rs +++ b/src/liballoc/raw_vec.rs @@ -445,6 +445,7 @@ impl<T> RawVec<T> { } impl<T> Drop for RawVec<T> { + #[unsafe_destructor_blind_to_params] /// Frees the memory owned by the RawVec *without* trying to Drop its contents. fn drop(&mut self) { let elem_size = mem::size_of::<T>(); diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 57e82720e8b..62463ecabbf 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -38,8 +38,14 @@ #![feature(ptr_as_ref)] #![feature(raw)] #![feature(staged_api)] +#![feature(dropck_parametricity)] #![cfg_attr(test, feature(test))] +// SNAP 1af31d4 +#![allow(unused_features)] +// SNAP 1af31d4 +#![allow(unused_attributes)] + extern crate alloc; use std::cell::{Cell, RefCell}; @@ -510,6 +516,7 @@ impl<T> TypedArena<T> { } impl<T> Drop for TypedArena<T> { + #[unsafe_destructor_blind_to_params] fn drop(&mut self) { unsafe { // Determine how much was filled. 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 diff --git a/src/libstd/collections/hash/table.rs b/src/libstd/collections/hash/table.rs index 32541353a0a..e8796dd10b4 100644 --- a/src/libstd/collections/hash/table.rs +++ b/src/libstd/collections/hash/table.rs @@ -999,6 +999,7 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> { } impl<K, V> Drop for RawTable<K, V> { + #[unsafe_destructor_blind_to_params] fn drop(&mut self) { if self.capacity == 0 || self.capacity == mem::POST_DROP_USIZE { return; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 10c7190ca0c..9af766ad2af 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -199,6 +199,11 @@ test(no_crate_inject, attr(deny(warnings))), test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] +// SNAP 1af31d4 +#![allow(unused_features)] +// SNAP 1af31d4 +#![allow(unused_attributes)] + #![feature(alloc)] #![feature(allow_internal_unstable)] #![feature(associated_consts)] @@ -241,6 +246,7 @@ #![feature(unboxed_closures)] #![feature(unicode)] #![feature(unique)] +#![feature(dropck_parametricity)] #![feature(unsafe_no_drop_flag, filling_drop)] #![feature(decode_utf16)] #![feature(unwind_attributes)] diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index e364716bdf2..e134e5617dc 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -136,9 +136,9 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option<u32>, Status // switch to Accepted; see RFC 320) ("unsafe_no_drop_flag", "1.0.0", None, Active), - // Allows using the unsafe_destructor_blind_to_params attribute - // (Needs an RFC link) - ("unsafe_destructor_blind_to_params", "1.3.0", Some(28498), Active), + // Allows using the unsafe_destructor_blind_to_params attribute; + // RFC 1238 + ("dropck_parametricity", "1.3.0", Some(28498), Active), // Allows the use of custom attributes; RFC 572 ("custom_attribute", "1.0.0", None, Active), @@ -345,7 +345,7 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat and may be removed in the future")), ("unsafe_destructor_blind_to_params", Normal, - Gated("unsafe_destructor_blind_to_params", + Gated("dropck_parametricity", "unsafe_destructor_blind_to_params has unstable semantics \ and may be removed in the future")), ("unwind", Whitelisted, Gated("unwind_attributes", "#[unwind] is experimental")), diff --git a/src/test/run-pass/issue-24805-dropck-itemless.rs b/src/test/run-pass/issue-24805-dropck-itemless.rs index 4512bcc2000..9fa48202298 100644 --- a/src/test/run-pass/issue-24805-dropck-itemless.rs +++ b/src/test/run-pass/issue-24805-dropck-itemless.rs @@ -13,6 +13,8 @@ #![allow(non_camel_case_types)] +#![feature(dropck_parametricity)] + trait UserDefined { } impl UserDefined for i32 { } @@ -26,7 +28,10 @@ impl<'a, T> UserDefined for &'a T { } macro_rules! impl_drop { ($Bound:ident, $Id:ident) => { struct $Id<T:$Bound>(T); - impl <T:$Bound> Drop for $Id<T> { fn drop(&mut self) { } } + impl <T:$Bound> Drop for $Id<T> { + #[unsafe_destructor_blind_to_params] + fn drop(&mut self) { } + } } } |
