diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-28 20:05:15 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-28 20:05:15 +0100 |
| commit | 975a0e0141c94a09cf4cba4499ce981da643d07e (patch) | |
| tree | 5d40487dd9e61409c6077c76191bc9d082b71378 /compiler/rustc_codegen_ssa/src | |
| parent | 934079180da6e75ee2398d0342857797df5c7a49 (diff) | |
| parent | d316aba04c4644093ba07d1ec8d334b599b8eb01 (diff) | |
| download | rust-975a0e0141c94a09cf4cba4499ce981da643d07e.tar.gz rust-975a0e0141c94a09cf4cba4499ce981da643d07e.zip | |
Rollup merge of #94414 - DrMeepster:box_alloc_ice2, r=tmiasko
Fix ICE when using Box<T, A> with large A A sequel to #94043 that fixes #81270 and #92054 (duplicate).
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/place.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/place.rs b/compiler/rustc_codegen_ssa/src/mir/place.rs index 6976999c0e4..809d6447908 100644 --- a/compiler/rustc_codegen_ssa/src/mir/place.rs +++ b/compiler/rustc_codegen_ssa/src/mir/place.rs @@ -453,7 +453,18 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { }; for elem in place_ref.projection[base..].iter() { cg_base = match elem.clone() { - mir::ProjectionElem::Deref => bx.load_operand(cg_base).deref(bx.cx()), + mir::ProjectionElem::Deref => { + // custom allocators can change box's abi, making it unable to be derefed directly + if cg_base.layout.ty.is_box() + && matches!(cg_base.layout.abi, Abi::Aggregate { .. } | Abi::Uninhabited) + { + let ptr = cg_base.project_field(bx, 0).project_field(bx, 0); + + bx.load_operand(ptr).deref(bx.cx()) + } else { + bx.load_operand(cg_base).deref(bx.cx()) + } + } mir::ProjectionElem::Field(ref field, _) => { cg_base.project_field(bx, field.index()) } |
