mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Use Layout::new
consistently in DroplessArena::alloc
.
This commit is contained in:
parent
51edc21990
commit
98d97b7323
@ -501,12 +501,13 @@ impl DroplessArena {
|
|||||||
assert!(!mem::needs_drop::<T>());
|
assert!(!mem::needs_drop::<T>());
|
||||||
assert!(mem::size_of::<T>() != 0);
|
assert!(mem::size_of::<T>() != 0);
|
||||||
|
|
||||||
let mem = if let Some(a) = self.alloc_raw_without_grow(Layout::for_value::<T>(&object)) {
|
let layout = Layout::new::<T>();
|
||||||
|
let mem = if let Some(a) = self.alloc_raw_without_grow(layout) {
|
||||||
a
|
a
|
||||||
} else {
|
} else {
|
||||||
// No free space left. Allocate a new chunk to satisfy the request.
|
// No free space left. Allocate a new chunk to satisfy the request.
|
||||||
// On failure the grow will panic or abort.
|
// On failure the grow will panic or abort.
|
||||||
self.grow_and_alloc_raw(Layout::new::<T>())
|
self.grow_and_alloc_raw(layout)
|
||||||
} as *mut T;
|
} as *mut T;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
Loading…
Reference in New Issue
Block a user