.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);
// build-pass
#![feature(allocator_api)]
+#![allow(unused_must_use)]
use std::alloc::Allocator;
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);
}