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 RawVec { } impl Drop for RawVec { + #[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::(); 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 TypedArena { } impl Drop for TypedArena { + #[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 DoubleEndedIterator for RawItems { } impl Drop for RawItems { + #[unsafe_destructor_blind_to_params] fn drop(&mut self) { for _ in self {} } } impl Drop for Node { + #[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 TraversalImpl for MoveTraversalImpl { } impl Drop for MoveTraversalImpl { + #[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 LinkedList { #[stable(feature = "rust1", since = "1.0.0")] impl Drop for LinkedList { + #[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 Ord for Vec { #[stable(feature = "rust1", since = "1.0.0")] impl Drop for Vec { + #[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 Clone for VecDeque { #[stable(feature = "rust1", since = "1.0.0")] impl Drop for VecDeque { + #[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 Clone for RawTable { } impl Drop for RawTable { + #[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, 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); - impl Drop for $Id { fn drop(&mut self) { } } + impl Drop for $Id { + #[unsafe_destructor_blind_to_params] + fn drop(&mut self) { } + } } }