mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Add additional extract_field
/ project_field
to take into account extra level of struct nesting.
This commit is contained in:
parent
2a91eeac1a
commit
c58af72a03
@ -448,7 +448,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
|
||||
// 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);
|
||||
// Extract `Box<T>` -> `Unique<T>` -> `NonNull<T>` -> `*const T`
|
||||
let ptr =
|
||||
cg_base.extract_field(bx, 0).extract_field(bx, 0).extract_field(bx, 0);
|
||||
|
||||
ptr.deref(bx.cx())
|
||||
} else {
|
||||
@ -464,7 +466,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
mir::ProjectionElem::Deref => {
|
||||
// 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.project_field(bx, 0).project_field(bx, 0);
|
||||
// Project `Box<T>` -> `Unique<T>` -> `NonNull<T>` -> `*const T`
|
||||
let ptr =
|
||||
cg_base.project_field(bx, 0).project_field(bx, 0).project_field(bx, 0);
|
||||
|
||||
bx.load_operand(ptr).deref(bx.cx())
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user