Skip to content

Commit

Permalink
&mut -> *mut
Browse files Browse the repository at this point in the history
Summary: I suspect it is illegal to create `&mut T` for uninitialized `T`.

Reviewed By: ndmitchell

Differential Revision: D56380598

fbshipit-source-id: 4502c2aa203ca43eb289e3adf405657aa6873d28
  • Loading branch information
stepancheg authored and facebook-github-bot committed Apr 20, 2024
1 parent d1cbf9b commit a495284
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions starlark/src/values/layout/heap/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ use bumpalo::Bump;
use dupe::Dupe;
use starlark_map::small_map::SmallMap;

use crate::cast::transmute;
use crate::collections::StarlarkHashValue;
use crate::values::layout::aligned_size::AlignedSize;
use crate::values::layout::avalue::starlark_str;
Expand Down Expand Up @@ -216,19 +215,16 @@ impl<A: ArenaAllocator> Arena<A> {
// so very important to put in a current vtable
// We always alloc at least one pointer worth of space, so can write in a one-ST blackhole

let p = p.as_mut_ptr();

let x = BlackHole(T::alloc_size_for_extra_len(extra_len));
let p = unsafe {
transmute!(
&mut MaybeUninit<AValueRepr<T>>,
&mut MaybeUninit<AValueRepr<BlackHole>>,
p
)
};
let p = p.write(AValueRepr {
header: AValueHeader(AValueVTable::new_black_hole()),
payload: x,
});
let p = unsafe { transmute!(&mut AValueRepr<BlackHole>, &mut AValueRepr<T>, p) };
unsafe {
let p = p as *mut AValueRepr<BlackHole>;
p.write(AValueRepr {
header: AValueHeader(AValueVTable::new_black_hole()),
payload: x,
});
}

(
Reservation {
Expand Down

0 comments on commit a495284

Please sign in to comment.