about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAman Arora <me@aman-arora.com>2021-09-21 04:04:50 -0400
committerAman Arora <me@aman-arora.com>2021-09-21 04:06:00 -0400
commit099a34cd95bf54e859f7dd03a21fe8202a5e3f70 (patch)
tree2c7da8bc61b08615e77a19cad9e65a786d6ac0e2
parent95cfbe43d2d5663e2af1877d7a1a93801d23f532 (diff)
downloadrust-099a34cd95bf54e859f7dd03a21fe8202a5e3f70.tar.gz
rust-099a34cd95bf54e859f7dd03a21fe8202a5e3f70.zip
2229: Annotate stdlib with insignficant dtors
-rw-r--r--library/alloc/src/collections/btree/map.rs2
-rw-r--r--library/alloc/src/collections/linked_list.rs1
-rw-r--r--library/alloc/src/collections/vec_deque/mod.rs1
-rw-r--r--library/alloc/src/rc.rs1
-rw-r--r--library/alloc/src/vec/into_iter.rs1
-rw-r--r--library/alloc/src/vec/mod.rs1
-rw-r--r--library/core/src/array/iter.rs1
-rw-r--r--library/std/src/lazy.rs1
8 files changed, 9 insertions, 0 deletions
diff --git a/library/alloc/src/collections/btree/map.rs b/library/alloc/src/collections/btree/map.rs
index 501a604e7f7..5486f862718 100644
--- a/library/alloc/src/collections/btree/map.rs
+++ b/library/alloc/src/collections/btree/map.rs
@@ -162,6 +162,7 @@ pub struct BTreeMap<K, V> {
 
 #[stable(feature = "btree_drop", since = "1.7.0")]
 unsafe impl<#[may_dangle] K, #[may_dangle] V> Drop for BTreeMap<K, V> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         drop(unsafe { ptr::read(self) }.into_iter())
     }
@@ -1459,6 +1460,7 @@ impl<K, V> IntoIterator for BTreeMap<K, V> {
 
 #[stable(feature = "btree_drop", since = "1.7.0")]
 impl<K, V> Drop for IntoIter<K, V> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         struct DropGuard<'a, K, V>(&'a mut IntoIter<K, V>);
 
diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs
index 9d45c5082db..9f390cfc955 100644
--- a/library/alloc/src/collections/linked_list.rs
+++ b/library/alloc/src/collections/linked_list.rs
@@ -975,6 +975,7 @@ impl<T> LinkedList<T> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 unsafe impl<#[may_dangle] T> Drop for LinkedList<T> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         struct DropGuard<'a, T>(&'a mut LinkedList<T>);
 
diff --git a/library/alloc/src/collections/vec_deque/mod.rs b/library/alloc/src/collections/vec_deque/mod.rs
index 10144cc17bf..a79aac39c71 100644
--- a/library/alloc/src/collections/vec_deque/mod.rs
+++ b/library/alloc/src/collections/vec_deque/mod.rs
@@ -130,6 +130,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for VecDeque<T, A> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 unsafe impl<#[may_dangle] T, A: Allocator> Drop for VecDeque<T, A> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         /// Runs the destructor for all items in the slice when it gets dropped (normally or
         /// during unwinding).
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index 0814652a5d4..8b0d7f19b19 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -1441,6 +1441,7 @@ unsafe impl<#[may_dangle] T: ?Sized> Drop for Rc<T> {
     /// drop(foo);    // Doesn't print anything
     /// drop(foo2);   // Prints "dropped!"
     /// ```
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         unsafe {
             self.inner().dec_strong();
diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs
index 0bd152f17a6..36ef96e6595 100644
--- a/library/alloc/src/vec/into_iter.rs
+++ b/library/alloc/src/vec/into_iter.rs
@@ -246,6 +246,7 @@ impl<T: Clone, A: Allocator + Clone> Clone for IntoIter<T, A> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 unsafe impl<#[may_dangle] T, A: Allocator> Drop for IntoIter<T, A> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         struct DropGuard<'a, T, A: Allocator>(&'a mut IntoIter<T, A>);
 
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 87a0d371815..ef44b6ef82f 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -2746,6 +2746,7 @@ impl<T: Ord, A: Allocator> Ord for Vec<T, A> {
 
 #[stable(feature = "rust1", since = "1.0.0")]
 unsafe impl<#[may_dangle] T, A: Allocator> Drop for Vec<T, A> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         unsafe {
             // use drop for [T]
diff --git a/library/core/src/array/iter.rs b/library/core/src/array/iter.rs
index ecdbf098819..06867fd8b84 100644
--- a/library/core/src/array/iter.rs
+++ b/library/core/src/array/iter.rs
@@ -180,6 +180,7 @@ impl<T, const N: usize> DoubleEndedIterator for IntoIter<T, N> {
 
 #[stable(feature = "array_value_iter_impls", since = "1.40.0")]
 impl<T, const N: usize> Drop for IntoIter<T, N> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         // SAFETY: This is safe: `as_mut_slice` returns exactly the sub-slice
         // of elements that have not been moved out yet and that remain
diff --git a/library/std/src/lazy.rs b/library/std/src/lazy.rs
index 5afdb799f0c..3bb4cacb02a 100644
--- a/library/std/src/lazy.rs
+++ b/library/std/src/lazy.rs
@@ -492,6 +492,7 @@ impl<T> SyncOnceCell<T> {
 }
 
 unsafe impl<#[may_dangle] T> Drop for SyncOnceCell<T> {
+    #[rustc_insignificant_dtor]
     fn drop(&mut self) {
         if self.is_initialized() {
             // SAFETY: The cell is initialized and being dropped, so it can't