From 8c3406f8bc3c20cb38c44514f1017c25ee566cd5 Mon Sep 17 00:00:00 2001 From: ouz-a Date: Mon, 28 Aug 2023 11:19:19 +0300 Subject: [PATCH] Add docs, remove code, change subtyper code --- src/base.rs | 4 +--- src/value_and_place.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) 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>,