fix another assumption about box
This commit is contained in:
parent
c5a43b8d39
commit
9d72dd54d0
@ -126,7 +126,14 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
|||||||
.ty;
|
.ty;
|
||||||
let (llptr, llextra) = match self.val {
|
let (llptr, llextra) = match self.val {
|
||||||
OperandValue::Immediate(llptr) => (llptr, None),
|
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),
|
OperandValue::Ref(..) => bug!("Deref of by-Ref operand {:?}", self),
|
||||||
};
|
};
|
||||||
let layout = cx.layout_of(projected_ty);
|
let layout = cx.layout_of(projected_ty);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// build-pass
|
// build-pass
|
||||||
#![feature(allocator_api)]
|
#![feature(allocator_api)]
|
||||||
|
#![allow(unused_must_use)]
|
||||||
|
|
||||||
use std::alloc::Allocator;
|
use std::alloc::Allocator;
|
||||||
|
|
||||||
@ -20,4 +21,9 @@ unsafe impl Allocator for BigAllocator {
|
|||||||
fn main() {
|
fn main() {
|
||||||
Box::new_in((), &std::alloc::Global);
|
Box::new_in((), &std::alloc::Global);
|
||||||
Box::new_in((), BigAllocator([0; 2]));
|
Box::new_in((), BigAllocator([0; 2]));
|
||||||
|
generic_function(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generic_function<T>(val: T) {
|
||||||
|
*Box::new_in(val, &std::alloc::Global);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user