diff options
| author | DrMeepster <19316085+DrMeepster@users.noreply.github.com> | 2022-02-27 00:48:17 -0800 |
|---|---|---|
| committer | DrMeepster <19316085+DrMeepster@users.noreply.github.com> | 2022-02-27 00:48:17 -0800 |
| commit | bfa7d44823717c30bc21abc1ca3675d0b78c80a2 (patch) | |
| tree | 346f9e6b4d595e4dc2b8f32327bf3f9b0aadcc03 /compiler/rustc_codegen_ssa/src | |
| parent | 6cbc6c35e4b0c948114619a1c883a75b731d32c5 (diff) | |
| download | rust-bfa7d44823717c30bc21abc1ca3675d0b78c80a2.tar.gz rust-bfa7d44823717c30bc21abc1ca3675d0b78c80a2.zip | |
fix box icing when it has aggregate abi
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..aee385ab050 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 { .. }) + { + 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()) } |
