diff --git a/src/base.rs b/src/base.rs index 06780567fb8..a13d3a0e115 100644 --- a/src/base.rs +++ b/src/base.rs @@ -872,13 +872,11 @@ pub(crate) fn codegen_place<'tcx>( for elem in place.projection { match elem { - PlaceElem::Subtype(_) => { - continue; - } PlaceElem::Deref => { cplace = cplace.place_deref(fx); } PlaceElem::OpaqueCast(ty) => bug!("encountered OpaqueCast({ty}) in codegen"), + PlaceElem::Subtype(ty) => cplace = cplace.place_transmute_type(fx, ty), PlaceElem::Field(field, _ty) => { cplace = cplace.place_field(fx, field); } diff --git a/src/value_and_place.rs b/src/value_and_place.rs index d4273c0b593..34cde0a0e78 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -674,6 +674,14 @@ fn transmute_scalar<'tcx>( } } + pub(crate) fn place_transmute_type( + self, + fx: &mut FunctionCx<'_, '_, 'tcx>, + ty: Ty<'tcx>, + ) -> CPlace<'tcx> { + CPlace { inner: self.inner, layout: fx.layout_of(fx.monomorphize(ty)) } + } + pub(crate) fn place_field( self, fx: &mut FunctionCx<'_, '_, 'tcx>,