about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGiacomo Stevanato <giaco.stevanato@gmail.com>2022-09-10 15:00:37 +0200
committerGiacomo Stevanato <giaco.stevanato@gmail.com>2022-10-03 20:23:54 +0200
commit1750c7bdd36ec18324423bd30867e39d787d5977 (patch)
treed17cfeb4b650fb1745310f7df5b432f2000ac96c
parentdad049cb5cb3d259836cfe6a9160521d9d4809ca (diff)
downloadrust-1750c7bdd36ec18324423bd30867e39d787d5977.tar.gz
rust-1750c7bdd36ec18324423bd30867e39d787d5977.zip
Clarify documentation
-rw-r--r--library/alloc/src/vec/in_place_collect.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/library/alloc/src/vec/in_place_collect.rs b/library/alloc/src/vec/in_place_collect.rs
index 83ed3d915a2..9f2555ee161 100644
--- a/library/alloc/src/vec/in_place_collect.rs
+++ b/library/alloc/src/vec/in_place_collect.rs
@@ -194,11 +194,10 @@ where
             );
         }
 
-        // Drop any remaining values at the tail of the source but prevent drop of the allocation
-        // itself once IntoIter goes out of scope.
-        // If the drop panics then we also try to drop the destination buffer and its elements.
+        // The ownership of the allocation and the new `T` values is temporarily moved into `dst_guard`.
         // This is safe because `forget_allocation_drop_remaining` immediately forgets the allocation
-        // and won't panic before that.
+        // before any panic can occur in order to avoid any double free, and then proceeds to drop
+        // any remaining values at the tail of the source.
         //
         // Note: This access to the source wouldn't be allowed by the TrustedRandomIteratorNoCoerce
         // contract (used by SpecInPlaceCollect below). But see the "O(1) collect" section in the