Skip to content

Commit

Permalink
Rollup merge of rust-lang#38664 - apasel422:may-dangle, r=pnkfelix
Browse files Browse the repository at this point in the history
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]`

CC rust-lang#34761

r? @pnkfelix
  • Loading branch information
sanxiyn authored Jan 10, 2017
2 parents 4d3d2c7 + ca9b07b commit d350c9b
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 29 deletions.
3 changes: 1 addition & 2 deletions src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ impl<T: ?Sized> Arc<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for Arc<T> {
unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
/// Drops the `Arc`.
///
/// This will decrement the strong reference count. If the strong reference
Expand Down Expand Up @@ -736,7 +736,6 @@ impl<T: ?Sized> Drop for Arc<T> {
/// drop(foo); // Doesn't print anything
/// drop(foo2); // Prints "dropped!"
/// ```
#[unsafe_destructor_blind_to_params]
#[inline]
fn drop(&mut self) {
// Because `fetch_sub` is already atomic, we do not need to synchronize
Expand Down
3 changes: 2 additions & 1 deletion src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@
#![feature(const_fn)]
#![feature(core_intrinsics)]
#![feature(custom_attribute)]
#![feature(dropck_parametricity)]
#![feature(dropck_eyepatch)]
#![cfg_attr(not(test), feature(exact_size_is_empty))]
#![feature(fundamental)]
#![feature(generic_param_attrs)]
#![feature(lang_items)]
#![feature(needs_allocator)]
#![feature(optin_builtin_traits)]
Expand Down
3 changes: 1 addition & 2 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,8 +539,7 @@ impl<T> RawVec<T> {
}
}

impl<T> Drop for RawVec<T> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] T> Drop for RawVec<T> {
/// Frees the memory owned by the RawVec *without* trying to Drop its contents.
fn drop(&mut self) {
let elem_size = mem::size_of::<T>();
Expand Down
3 changes: 1 addition & 2 deletions src/liballoc/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ impl<T: ?Sized> Deref for Rc<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for Rc<T> {
unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
/// Drops the `Rc`.
///
/// This will decrement the strong reference count. If the strong reference
Expand Down Expand Up @@ -672,7 +672,6 @@ impl<T: ?Sized> Drop for Rc<T> {
/// drop(foo); // Doesn't print anything
/// drop(foo2); // Prints "dropped!"
/// ```
#[unsafe_destructor_blind_to_params]
fn drop(&mut self) {
unsafe {
let ptr = *self.ptr;
Expand Down
7 changes: 3 additions & 4 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

#![feature(alloc)]
#![feature(core_intrinsics)]
#![feature(dropck_eyepatch)]
#![feature(heap_api)]
#![feature(heap_api)]
#![feature(generic_param_attrs)]
#![feature(staged_api)]
#![feature(dropck_parametricity)]
#![cfg_attr(test, feature(test))]

#![allow(deprecated)]
Expand Down Expand Up @@ -258,8 +258,7 @@ impl<T> TypedArena<T> {
}
}

impl<T> Drop for TypedArena<T> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] T> Drop for TypedArena<T> {
fn drop(&mut self) {
unsafe {
// Determine how much was filled.
Expand Down
3 changes: 1 addition & 2 deletions src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ pub struct BTreeMap<K, V> {
}

#[stable(feature = "btree_drop", since = "1.7.0")]
impl<K, V> Drop for BTreeMap<K, V> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap<K, V> {
fn drop(&mut self) {
unsafe {
for _ in ptr::read(self).into_iter() {
Expand Down
3 changes: 2 additions & 1 deletion src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
#![feature(box_syntax)]
#![cfg_attr(not(test), feature(char_escape_debug))]
#![feature(core_intrinsics)]
#![feature(dropck_parametricity)]
#![feature(dropck_eyepatch)]
#![feature(exact_size_is_empty)]
#![feature(fmt_internals)]
#![feature(fused)]
#![feature(generic_param_attrs)]
#![feature(heap_api)]
#![feature(inclusive_range)]
#![feature(lang_items)]
Expand Down
3 changes: 1 addition & 2 deletions src/libcollections/linked_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,7 @@ impl<T> LinkedList<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Drop for LinkedList<T> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
fn drop(&mut self) {
while let Some(_) = self.pop_front_node() {}
}
Expand Down
6 changes: 2 additions & 4 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1786,8 +1786,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]
unsafe impl<#[may_dangle] T> Drop for Vec<T> {
fn drop(&mut self) {
unsafe {
// use drop for [T]
Expand Down Expand Up @@ -2056,8 +2055,7 @@ impl<T: Clone> Clone for IntoIter<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T> Drop for IntoIter<T> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] T> Drop for IntoIter<T> {
fn drop(&mut self) {
// destroy the remaining elements
for _x in self.by_ref() {}
Expand Down
3 changes: 1 addition & 2 deletions src/libcollections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,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]
unsafe impl<#[may_dangle] T> Drop for VecDeque<T> {
fn drop(&mut self) {
let (front, back) = self.as_mut_slices();
unsafe {
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/collections/hash/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,7 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> {
}
}

impl<K, V> Drop for RawTable<K, V> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
fn drop(&mut self) {
if self.capacity == 0 {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,14 @@
#![feature(const_fn)]
#![feature(core_float)]
#![feature(core_intrinsics)]
#![feature(dropck_parametricity)]
#![feature(dropck_eyepatch)]
#![feature(exact_size_is_empty)]
#![feature(float_extras)]
#![feature(float_from_str_radix)]
#![feature(fn_traits)]
#![feature(fnbox)]
#![feature(fused)]
#![feature(generic_param_attrs)]
#![feature(hashmap_hasher)]
#![feature(heap_api)]
#![feature(inclusive_range)]
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/sync/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ impl<T: ?Sized> Mutex<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for Mutex<T> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
fn drop(&mut self) {
// This is actually safe b/c we know that there is no further usage of
// this mutex (it's up to the user to arrange for a mutex to get
Expand Down
3 changes: 1 addition & 2 deletions src/libstd/sync/rwlock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ impl<T: ?Sized> RwLock<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: ?Sized> Drop for RwLock<T> {
#[unsafe_destructor_blind_to_params]
unsafe impl<#[may_dangle] T: ?Sized> Drop for RwLock<T> {
fn drop(&mut self) {
// IMPORTANT: This code needs to be kept in sync with `RwLock::into_inner`.
unsafe { self.inner.destroy() }
Expand Down

0 comments on commit d350c9b

Please sign in to comment.