We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a85e949 commit 2705caeCopy full SHA for 2705cae
compiler/rustc_arena/src/lib.rs
@@ -217,8 +217,12 @@ impl<T> TypedArena<T> {
217
let mut chunks = self.chunks.borrow_mut();
218
let mut new_cap;
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>();
+ // If a type is `!needs_drop`, we don't need to keep track of how many elements
+ // 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
+ }
226
227
// If the previous chunk's len is less than HUGE_PAGE
228
// bytes, then this chunk will be least double the previous
0 commit comments