72
72
//! This is handled by the [`InPlaceDrop`] guard for sink items (`U`) and by
73
73
//! [`vec::IntoIter::forget_allocation_drop_remaining()`] for remaining source items (`T`).
74
74
//!
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
76
76
//! the already collected sink items (`U`) and freeing the allocation.
77
77
//!
78
78
//! [`vec::IntoIter::forget_allocation_drop_remaining()`]: super::IntoIter::forget_allocation_drop_remaining()
@@ -158,11 +158,12 @@ use crate::alloc::{handle_alloc_error, Global};
158
158
use core:: alloc:: Allocator ;
159
159
use core:: alloc:: Layout ;
160
160
use core:: iter:: { InPlaceIterable , SourceIter , TrustedRandomAccessNoCoerce } ;
161
+ use core:: marker:: PhantomData ;
161
162
use core:: mem:: { self , ManuallyDrop , SizedTypeProperties } ;
162
163
use core:: num:: NonZeroUsize ;
163
164
use core:: ptr:: { self , NonNull } ;
164
165
165
- use super :: { InPlaceDrop , InPlaceDstBufDrop , SpecFromIter , SpecFromIterNested , Vec } ;
166
+ use super :: { InPlaceDrop , InPlaceDstDataSrcBufDrop , SpecFromIter , SpecFromIterNested , Vec } ;
166
167
167
168
const fn in_place_collectible < DEST , SRC > (
168
169
step_merge : Option < NonZeroUsize > ,
@@ -265,7 +266,7 @@ where
265
266
) ;
266
267
}
267
268
268
- // The ownership of the allocation and the new `T` values is temporarily moved into `dst_guard`.
269
+ // The ownership of the source allocation and the new `T` values is temporarily moved into `dst_guard`.
269
270
// This is safe because
270
271
// * `forget_allocation_drop_remaining` immediately forgets the allocation
271
272
// before any panic can occur in order to avoid any double free, and then proceeds to drop
@@ -276,7 +277,8 @@ where
276
277
// Note: This access to the source wouldn't be allowed by the TrustedRandomIteratorNoCoerce
277
278
// contract (used by SpecInPlaceCollect below). But see the "O(1) collect" section in the
278
279
// module documentation why this is ok anyway.
279
- let dst_guard = InPlaceDstBufDrop { ptr : dst_buf, len, cap : dst_cap } ;
280
+ let dst_guard =
281
+ InPlaceDstDataSrcBufDrop { ptr : dst_buf, len, src_cap, src : PhantomData :: < I :: Src > } ;
280
282
src. forget_allocation_drop_remaining ( ) ;
281
283
282
284
// Adjust the allocation if the source had a capacity in bytes that wasn't a multiple
0 commit comments