7272//! This is handled by the [`InPlaceDrop`] guard for sink items (`U`) and by
7373//! [`vec::IntoIter::forget_allocation_drop_remaining()`] for remaining source items (`T`).
7474//!
75- //! If dropping any remaining source item (`T`) panics then [`InPlaceDstBufDrop `] will handle dropping
75+ //! If dropping any remaining source item (`T`) panics then [`InPlaceDstDataSrcBufDrop `] will handle dropping
7676//! the already collected sink items (`U`) and freeing the allocation.
7777//!
7878//! [`vec::IntoIter::forget_allocation_drop_remaining()`]: super::IntoIter::forget_allocation_drop_remaining()
@@ -158,11 +158,12 @@ use crate::alloc::{handle_alloc_error, Global};
158158use core:: alloc:: Allocator ;
159159use core:: alloc:: Layout ;
160160use core:: iter:: { InPlaceIterable , SourceIter , TrustedRandomAccessNoCoerce } ;
161+ use core:: marker:: PhantomData ;
161162use core:: mem:: { self , ManuallyDrop , SizedTypeProperties } ;
162163use core:: num:: NonZeroUsize ;
163164use core:: ptr:: { self , NonNull } ;
164165
165- use super :: { InPlaceDrop , InPlaceDstBufDrop , SpecFromIter , SpecFromIterNested , Vec } ;
166+ use super :: { InPlaceDrop , InPlaceDstDataSrcBufDrop , SpecFromIter , SpecFromIterNested , Vec } ;
166167
167168const fn in_place_collectible < DEST , SRC > (
168169 step_merge : Option < NonZeroUsize > ,
@@ -262,7 +263,7 @@ where
262263 ) ;
263264 }
264265
265- // The ownership of the allocation and the new `T` values is temporarily moved into `dst_guard`.
266+ // The ownership of the source allocation and the new `T` values is temporarily moved into `dst_guard`.
266267 // This is safe because
267268 // * `forget_allocation_drop_remaining` immediately forgets the allocation
268269 // before any panic can occur in order to avoid any double free, and then proceeds to drop
@@ -273,7 +274,8 @@ where
273274 // Note: This access to the source wouldn't be allowed by the TrustedRandomIteratorNoCoerce
274275 // contract (used by SpecInPlaceCollect below). But see the "O(1) collect" section in the
275276 // module documentation why this is ok anyway.
276- let dst_guard = InPlaceDstBufDrop { ptr : dst_buf, len, cap : dst_cap } ;
277+ let dst_guard =
278+ InPlaceDstDataSrcBufDrop { ptr : dst_buf, len, src_cap, src : PhantomData :: < I :: Src > } ;
277279 src. forget_allocation_drop_remaining ( ) ;
278280
279281 // Adjust the allocation if the alignment didn't match or the source had a capacity in bytes
0 commit comments