fix other source of box deref
This commit is contained in:
parent
ece64ed3f5
commit
09ccc63624
2 changed files with 23 additions and 3 deletions
|
@ -441,11 +441,19 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
.find(|elem| matches!(elem.1, mir::ProjectionElem::Deref))
|
||||
{
|
||||
base = elem.0 + 1;
|
||||
self.codegen_consume(
|
||||
let cg_base = self.codegen_consume(
|
||||
bx,
|
||||
mir::PlaceRef { projection: &place_ref.projection[..elem.0], ..place_ref },
|
||||
)
|
||||
.deref(bx.cx())
|
||||
);
|
||||
|
||||
// a box with a non-zst allocator should not be directly dereferenced
|
||||
if cg_base.layout.ty.is_box() && !cg_base.layout.field(cx, 1).is_zst() {
|
||||
let ptr = cg_base.extract_field(bx, 0).extract_field(bx, 0);
|
||||
|
||||
ptr.deref(bx.cx())
|
||||
} else {
|
||||
cg_base.deref(bx.cx())
|
||||
}
|
||||
} else {
|
||||
bug!("using operand local {:?} as place", place_ref);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue