Skip to content

Commit 099a34c

Browse files
committed
2229: Annotate stdlib with insignficant dtors
1 parent 95cfbe4 commit 099a34c

File tree

8 files changed

+9
-0
lines changed

8 files changed

+9
-0
lines changed

Diff for: library/alloc/src/collections/btree/map.rs

+2
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ pub struct BTreeMap<K, V> {
162162

163163
#[stable(feature = "btree_drop", since = "1.7.0")]
164164
unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap<K, V> {
165+
#[rustc_insignificant_dtor]
165166
fn drop(&mut self) {
166167
drop(unsafe { ptr::read(self) }.into_iter())
167168
}
@@ -1459,6 +1460,7 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
14591460

14601461
#[stable(feature = "btree_drop", since = "1.7.0")]
14611462
impl<K, V> Drop for IntoIter<K, V> {
1463+
#[rustc_insignificant_dtor]
14621464
fn drop(&mut self) {
14631465
struct DropGuard<'a, K, V>(&'a mut IntoIter<K, V>);
14641466

Diff for: library/alloc/src/collections/linked_list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -975,6 +975,7 @@ impl<T> LinkedList<T> {
975975

976976
#[stable(feature = "rust1", since = "1.0.0")]
977977
unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
978+
#[rustc_insignificant_dtor]
978979
fn drop(&mut self) {
979980
struct DropGuard<'a, T>(&'a mut LinkedList<T>);
980981

Diff for: library/alloc/src/collections/vec_deque/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for VecDeque<T, A> {
130130

131131
#[stable(feature = "rust1", since = "1.0.0")]
132132
unsafe impl<#[may_dangle] T, A: Allocator> Drop for VecDeque<T, A> {
133+
#[rustc_insignificant_dtor]
133134
fn drop(&mut self) {
134135
/// Runs the destructor for all items in the slice when it gets dropped (normally or
135136
/// during unwinding).

Diff for: library/alloc/src/rc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
14411441
/// drop(foo); // Doesn't print anything
14421442
/// drop(foo2); // Prints "dropped!"
14431443
/// ```
1444+
#[rustc_insignificant_dtor]
14441445
fn drop(&mut self) {
14451446
unsafe {
14461447
self.inner().dec_strong();

Diff for: library/alloc/src/vec/into_iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for IntoIter<T, A> {
246246

247247
#[stable(feature = "rust1", since = "1.0.0")]
248248
unsafe impl<#[may_dangle] T, A: Allocator> Drop for IntoIter<T, A> {
249+
#[rustc_insignificant_dtor]
249250
fn drop(&mut self) {
250251
struct DropGuard<'a, T, A: Allocator>(&'a mut IntoIter<T, A>);
251252

Diff for: library/alloc/src/vec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,7 @@ impl<T: Ord, A: Allocator> Ord for Vec<T, A> {
27462746

27472747
#[stable(feature = "rust1", since = "1.0.0")]
27482748
unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
2749+
#[rustc_insignificant_dtor]
27492750
fn drop(&mut self) {
27502751
unsafe {
27512752
// use drop for [T]

Diff for: library/core/src/array/iter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
180180

181181
#[stable(feature = "array_value_iter_impls", since = "1.40.0")]
182182
impl<T, const N: usize> Drop for IntoIter<T, N> {
183+
#[rustc_insignificant_dtor]
183184
fn drop(&mut self) {
184185
// SAFETY: This is safe: `as_mut_slice` returns exactly the sub-slice
185186
// of elements that have not been moved out yet and that remain

Diff for: library/std/src/lazy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ impl<T> SyncOnceCell<T> {
492492
}
493493

494494
unsafe impl<#[may_dangle] T> Drop for SyncOnceCell<T> {
495+
#[rustc_insignificant_dtor]
495496
fn drop(&mut self) {
496497
if self.is_initialized() {
497498
// SAFETY: The cell is initialized and being dropped, so it can't

0 commit comments

Comments
 (0)