diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-17 23:01:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-17 23:01:01 +0100 |
| commit | 6dc62f421dcfb14f10a658de40c5140a083b3aed (patch) | |
| tree | 89606976363275711421702396354706e477cae8 /compiler/rustc_codegen_llvm/src | |
| parent | a4be35e3217e85e35693837cac5bdc8285add15a (diff) | |
| parent | d0b508e1a7d7f0408a782193c78e7b2ee052ef3b (diff) | |
| download | rust-6dc62f421dcfb14f10a658de40c5140a083b3aed.tar.gz rust-6dc62f421dcfb14f10a658de40c5140a083b3aed.zip | |
Rollup merge of #94043 - DrMeepster:box_alloc_ice, r=oli-obk
Fix ICE when using Box<T, A> with pointer sized A Fixes #78459 Note that using `Box<T, A>` with a more than pointer sized `A` or using a pointer sized `A` with a Box of a DST will produce a different ICE (#92054) which is not fixed by this PR.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/type_of.rs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/type_of.rs b/compiler/rustc_codegen_llvm/src/type_of.rs index 81d0603bc52..fafb9a6dbde 100644 --- a/compiler/rustc_codegen_llvm/src/type_of.rs +++ b/compiler/rustc_codegen_llvm/src/type_of.rs @@ -330,7 +330,9 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> { ty::Ref(..) | ty::RawPtr(_) => { return self.field(cx, index).llvm_type(cx); } - ty::Adt(def, _) if def.is_box() => { + // only wide pointer boxes are handled as pointers + // thin pointer boxes with scalar allocators are handled by the general logic below + ty::Adt(def, substs) if def.is_box() && cx.layout_of(substs.type_at(1)).is_zst() => { let ptr_ty = cx.tcx.mk_mut_ptr(self.ty.boxed_ty()); return cx.layout_of(ptr_ty).scalar_pair_element_llvm_type(cx, index, immediate); } |
