From 646d8d982264b91bd1b434b30b25845f21508c48 Mon Sep 17 00:00:00 2001 From: ouz-a Date: Sat, 30 Sep 2023 13:44:31 +0300 Subject: [PATCH] change is_subtype to relate_types --- src/base.rs | 2 +- src/value_and_place.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/base.rs b/src/base.rs index a13d3a0e115..0a451dad9d2 100644 --- a/src/base.rs +++ b/src/base.rs @@ -876,7 +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, ty), + 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 34cde0a0e78..09033cfb23f 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -674,12 +674,14 @@ 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(fx.monomorphize(ty)) } + CPlace { inner: self.inner, layout: fx.layout_of(ty) } } pub(crate) fn place_field(