So, the placement/box RFC assumes that one might eventually box/place DSTs. However, unlike sized types, it’s impossible to know the size of a DST without knowing the value. This means that, with DSTs, we’d need to compute the value before placing which would violate LTR execution order (and also kind of defeats the point of placement new/box).
In code, sized type placement desugars to:
let p = PLACE;
let mut place = Placer::make_place(p);
let raw_place = Place::pointer(&mut place);
let value = EXPR;
unsafe {
std::ptr::write(raw_place, value);
Place::finalize(place)
}
But, for DSTs, we can’t call Placer::make_place(p) until we know value because we need the value to get the size and alignment.
let p = PLACE;
let value = EXPR; // pretend this works.
let mut place = Placer::make_place(p, mem::align_of_val(&value), mem::size_of_val(&value));
let raw_place = Place::pointer(&mut place);
unsafe {
std::ptr::write(raw_place, value);
Place::finalize(place)
}