File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -217,8 +217,12 @@ impl<T> TypedArena<T> {
217
217
let mut chunks = self . chunks . borrow_mut ( ) ;
218
218
let mut new_cap;
219
219
if let Some ( last_chunk) = chunks. last_mut ( ) {
220
- let used_bytes = self . ptr . get ( ) as usize - last_chunk. start ( ) as usize ;
221
- last_chunk. entries = used_bytes / mem:: size_of :: < T > ( ) ;
220
+ // If a type is `!needs_drop`, we don't need to keep track of how many elements
221
+ // the chunk stores - the field will be ignored anyway.
222
+ if mem:: needs_drop :: < T > ( ) {
223
+ let used_bytes = self . ptr . get ( ) as usize - last_chunk. start ( ) as usize ;
224
+ last_chunk. entries = used_bytes / mem:: size_of :: < T > ( ) ;
225
+ }
222
226
223
227
// If the previous chunk's len is less than HUGE_PAGE
224
228
// bytes, then this chunk will be least double the previous
You can’t perform that action at this time.
0 commit comments