fix another assumption about box
This commit is contained in:
parent
c5a43b8d39
commit
9d72dd54d0
@ -126,7 +126,14 @@ pub fn deref<Cx: LayoutTypeMethods<'tcx>>(self, cx: &Cx) -> PlaceRef<'tcx, V> {
|
||||
.ty;
|
||||
let (llptr, llextra) = match self.val {
|
||||
OperandValue::Immediate(llptr) => (llptr, None),
|
||||
OperandValue::Pair(llptr, llextra) => (llptr, Some(llextra)),
|
||||
OperandValue::Pair(llptr, llextra) => {
|
||||
// if the box's allocator isn't a ZST, then "llextra" is actually the allocator
|
||||
if self.layout.ty.is_box() && !self.layout.field(cx, 1).is_zst() {
|
||||
(llptr, None)
|
||||
} else {
|
||||
(llptr, Some(llextra))
|
||||
}
|
||||
}
|
||||
OperandValue::Ref(..) => bug!("Deref of by-Ref operand {:?}", self),
|
||||
};
|
||||
let layout = cx.layout_of(projected_ty);
|
||||
|
@ -1,5 +1,6 @@
|
||||
// build-pass
|
||||
#![feature(allocator_api)]
|
||||
#![allow(unused_must_use)]
|
||||
|
||||
use std::alloc::Allocator;
|
||||
|
||||
@ -20,4 +21,9 @@ unsafe fn deallocate(&self, _: std::ptr::NonNull<u8>, _: std::alloc::Layout) {
|
||||
fn main() {
|
||||
Box::new_in((), &std::alloc::Global);
|
||||
Box::new_in((), BigAllocator([0; 2]));
|
||||
generic_function(0);
|
||||
}
|
||||
|
||||
fn generic_function<T>(val: T) {
|
||||
*Box::new_in(val, &std::alloc::Global);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user