Skip to content

Commit ae32f43

Browse files
committed
fix assumption that ScalarPair Box is always a fat pointer
1 parent 393fdc1 commit ae32f43

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

compiler/rustc_codegen_llvm/src/type_of.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
330330
ty::Ref(..) | ty::RawPtr(_) => {
331331
return self.field(cx, index).llvm_type(cx);
332332
}
333-
ty::Adt(def, _) if def.is_box() => {
333+
ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => {
334334
let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty());
335335
return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate);
336336
}

src/test/ui/box/issue-78459-ice.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// check-pass
2+
#![feature(allocator_api)]
3+
4+
fn main() {
5+
Box::new_in((), &std::alloc::Global);
6+
}

0 commit comments

Comments
 (0)