diff --git a/src/base.rs b/src/base.rs index 6d55fdc3074..0a451dad9d2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -876,6 +876,7 @@ pub(crate) fn codegen_place<'tcx>( cplace = cplace.place_deref(fx); } PlaceElem::OpaqueCast(ty) => bug!("encountered OpaqueCast({ty}) in codegen"), + PlaceElem::Subtype(ty) => cplace = cplace.place_transmute_type(fx, fx.monomorphize(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..45893a4f3ac 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -674,6 +674,16 @@ impl<'tcx> CPlace<'tcx> { } } + /// Used for `ProjectionElem::Subtype`, `ty` has to be monomorphized before + /// passed on. + pub(crate) fn place_transmute_type( + self, + fx: &mut FunctionCx<'_, '_, 'tcx>, + ty: Ty<'tcx>, + ) -> CPlace<'tcx> { + CPlace { inner: self.inner, layout: fx.layout_of(ty) } + } + pub(crate) fn place_field( self, fx: &mut FunctionCx<'_, '_, 'tcx>,