Skip to content

Commit a282e07

Browse files
Rollup merge of rust-lang#38664 - apasel422:may-dangle, r=pnkfelix
Replace uses of `#[unsafe_destructor_blind_to_params]` with `#[may_dangle]` CC rust-lang#34761 r? @pnkfelix
2 parents 8b05a91 + ca9b07b commit a282e07

File tree

14 files changed

+20
-29
lines changed

14 files changed

+20
-29
lines changed

src/liballoc/arc.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ impl<T: ?Sized> Arc<T> {
708708
}
709709

710710
#[stable(feature = "rust1", since = "1.0.0")]
711-
impl<T: ?Sized> Drop for Arc<T> {
711+
unsafe impl<#[may_dangle] T: ?Sized> Drop for Arc<T> {
712712
/// Drops the `Arc`.
713713
///
714714
/// This will decrement the strong reference count. If the strong reference
@@ -736,7 +736,6 @@ impl<T: ?Sized> Drop for Arc<T> {
736736
/// drop(foo); // Doesn't print anything
737737
/// drop(foo2); // Prints "dropped!"
738738
/// ```
739-
#[unsafe_destructor_blind_to_params]
740739
#[inline]
741740
fn drop(&mut self) {
742741
// Because `fetch_sub` is already atomic, we do not need to synchronize

src/liballoc/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@
7979
#![feature(const_fn)]
8080
#![feature(core_intrinsics)]
8181
#![feature(custom_attribute)]
82-
#![feature(dropck_parametricity)]
82+
#![feature(dropck_eyepatch)]
8383
#![cfg_attr(not(test), feature(exact_size_is_empty))]
8484
#![feature(fundamental)]
85+
#![feature(generic_param_attrs)]
8586
#![feature(lang_items)]
8687
#![feature(needs_allocator)]
8788
#![feature(optin_builtin_traits)]

src/liballoc/raw_vec.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,7 @@ impl<T> RawVec<T> {
539539
}
540540
}
541541

542-
impl<T> Drop for RawVec<T> {
543-
#[unsafe_destructor_blind_to_params]
542+
unsafe impl<#[may_dangle] T> Drop for RawVec<T> {
544543
/// Frees the memory owned by the RawVec *without* trying to Drop its contents.
545544
fn drop(&mut self) {
546545
let elem_size = mem::size_of::<T>();

src/liballoc/rc.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<T: ?Sized> Deref for Rc<T> {
644644
}
645645

646646
#[stable(feature = "rust1", since = "1.0.0")]
647-
impl<T: ?Sized> Drop for Rc<T> {
647+
unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
648648
/// Drops the `Rc`.
649649
///
650650
/// This will decrement the strong reference count. If the strong reference
@@ -672,7 +672,6 @@ impl<T: ?Sized> Drop for Rc<T> {
672672
/// drop(foo); // Doesn't print anything
673673
/// drop(foo2); // Prints "dropped!"
674674
/// ```
675-
#[unsafe_destructor_blind_to_params]
676675
fn drop(&mut self) {
677676
unsafe {
678677
let ptr = *self.ptr;

src/libarena/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@
3030

3131
#![feature(alloc)]
3232
#![feature(core_intrinsics)]
33+
#![feature(dropck_eyepatch)]
3334
#![feature(heap_api)]
34-
#![feature(heap_api)]
35+
#![feature(generic_param_attrs)]
3536
#![feature(staged_api)]
36-
#![feature(dropck_parametricity)]
3737
#![cfg_attr(test, feature(test))]
3838

3939
#![allow(deprecated)]
@@ -258,8 +258,7 @@ impl<T> TypedArena<T> {
258258
}
259259
}
260260

261-
impl<T> Drop for TypedArena<T> {
262-
#[unsafe_destructor_blind_to_params]
261+
unsafe impl<#[may_dangle] T> Drop for TypedArena<T> {
263262
fn drop(&mut self) {
264263
unsafe {
265264
// Determine how much was filled.

src/libcollections/btree/map.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ pub struct BTreeMap<K, V> {
137137
}
138138

139139
#[stable(feature = "btree_drop", since = "1.7.0")]
140-
impl<K, V> Drop for BTreeMap<K, V> {
141-
#[unsafe_destructor_blind_to_params]
140+
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap<K, V> {
142141
fn drop(&mut self) {
143142
unsafe {
144143
for _ in ptr::read(self).into_iter() {

src/libcollections/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@
3535
#![feature(box_syntax)]
3636
#![cfg_attr(not(test), feature(char_escape_debug))]
3737
#![feature(core_intrinsics)]
38-
#![feature(dropck_parametricity)]
38+
#![feature(dropck_eyepatch)]
3939
#![feature(exact_size_is_empty)]
4040
#![feature(fmt_internals)]
4141
#![feature(fused)]
42+
#![feature(generic_param_attrs)]
4243
#![feature(heap_api)]
4344
#![feature(inclusive_range)]
4445
#![feature(lang_items)]

src/libcollections/linked_list.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,7 @@ impl<T> LinkedList<T> {
726726
}
727727

728728
#[stable(feature = "rust1", since = "1.0.0")]
729-
impl<T> Drop for LinkedList<T> {
730-
#[unsafe_destructor_blind_to_params]
729+
unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
731730
fn drop(&mut self) {
732731
while let Some(_) = self.pop_front_node() {}
733732
}

src/libcollections/vec.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1763,8 +1763,7 @@ impl<T: Ord> Ord for Vec<T> {
17631763
}
17641764

17651765
#[stable(feature = "rust1", since = "1.0.0")]
1766-
impl<T> Drop for Vec<T> {
1767-
#[unsafe_destructor_blind_to_params]
1766+
unsafe impl<#[may_dangle] T> Drop for Vec<T> {
17681767
fn drop(&mut self) {
17691768
unsafe {
17701769
// use drop for [T]
@@ -2033,8 +2032,7 @@ impl<T: Clone> Clone for IntoIter<T> {
20332032
}
20342033

20352034
#[stable(feature = "rust1", since = "1.0.0")]
2036-
impl<T> Drop for IntoIter<T> {
2037-
#[unsafe_destructor_blind_to_params]
2035+
unsafe impl<#[may_dangle] T> Drop for IntoIter<T> {
20382036
fn drop(&mut self) {
20392037
// destroy the remaining elements
20402038
for _x in self.by_ref() {}

src/libcollections/vec_deque.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ impl<T: Clone> Clone for VecDeque<T> {
6969
}
7070

7171
#[stable(feature = "rust1", since = "1.0.0")]
72-
impl<T> Drop for VecDeque<T> {
73-
#[unsafe_destructor_blind_to_params]
72+
unsafe impl<#[may_dangle] T> Drop for VecDeque<T> {
7473
fn drop(&mut self) {
7574
let (front, back) = self.as_mut_slices();
7675
unsafe {

src/libstd/collections/hash/table.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1061,8 +1061,7 @@ impl<K: Clone, V: Clone> Clone for RawTable<K, V> {
10611061
}
10621062
}
10631063

1064-
impl<K, V> Drop for RawTable<K, V> {
1065-
#[unsafe_destructor_blind_to_params]
1064+
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for RawTable<K, V> {
10661065
fn drop(&mut self) {
10671066
if self.capacity == 0 {
10681067
return;

src/libstd/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,14 @@
250250
#![feature(const_fn)]
251251
#![feature(core_float)]
252252
#![feature(core_intrinsics)]
253-
#![feature(dropck_parametricity)]
253+
#![feature(dropck_eyepatch)]
254254
#![feature(exact_size_is_empty)]
255255
#![feature(float_extras)]
256256
#![feature(float_from_str_radix)]
257257
#![feature(fn_traits)]
258258
#![feature(fnbox)]
259259
#![feature(fused)]
260+
#![feature(generic_param_attrs)]
260261
#![feature(hashmap_hasher)]
261262
#![feature(heap_api)]
262263
#![feature(inclusive_range)]

src/libstd/sync/mutex.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,7 @@ impl<T: ?Sized> Mutex<T> {
280280
}
281281

282282
#[stable(feature = "rust1", since = "1.0.0")]
283-
impl<T: ?Sized> Drop for Mutex<T> {
284-
#[unsafe_destructor_blind_to_params]
283+
unsafe impl<#[may_dangle] T: ?Sized> Drop for Mutex<T> {
285284
fn drop(&mut self) {
286285
// This is actually safe b/c we know that there is no further usage of
287286
// this mutex (it's up to the user to arrange for a mutex to get

src/libstd/sync/rwlock.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,7 @@ impl<T: ?Sized> RwLock<T> {
310310
}
311311

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

0 commit comments

Comments
 (0)