Skip to content

Commit ff61915

Browse files
committed
Use Vec::push_mut when adding a chunk to arenas
1 parent d1d3ef4 commit ff61915

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

compiler/rustc_arena/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,9 @@ impl<T> TypedArena<T> {
287287
// Also ensure that this chunk can fit `additional`.
288288
new_cap = cmp::max(additional, new_cap);
289289

290-
let mut chunk = ArenaChunk::<T>::new(new_cap);
290+
let chunk = chunks.push_mut(ArenaChunk::<T>::new(new_cap));
291291
self.ptr.set(chunk.start());
292292
self.end.set(chunk.end());
293-
chunks.push(chunk);
294293
}
295294
}
296295

@@ -419,7 +418,7 @@ impl DroplessArena {
419418
// Also ensure that this chunk can fit `additional`.
420419
new_cap = cmp::max(additional, new_cap);
421420

422-
let mut chunk = ArenaChunk::new(align_up(new_cap, PAGE));
421+
let chunk = chunks.push_mut(ArenaChunk::new(align_up(new_cap, PAGE)));
423422
self.start.set(chunk.start());
424423

425424
// Align the end to DROPLESS_ALIGNMENT.
@@ -430,8 +429,6 @@ impl DroplessArena {
430429
debug_assert!(chunk.start().addr() <= end);
431430

432431
self.end.set(chunk.end().with_addr(end));
433-
434-
chunks.push(chunk);
435432
}
436433
}
437434

library/proc_macro/src/bridge/arena.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ impl Arena {
5858
// Also ensure that this chunk can fit `additional`.
5959
new_cap = cmp::max(additional, new_cap);
6060

61-
let mut chunk = Box::new_uninit_slice(new_cap);
61+
let chunk = chunks.push_mut(Box::new_uninit_slice(new_cap));
6262
let Range { start, end } = chunk.as_mut_ptr_range();
6363
self.start.set(start);
6464
self.end.set(end);
65-
chunks.push(chunk);
6665
}
6766

6867
/// Allocates a byte slice with specified size from the current memory

0 commit comments

Comments
 (0)