@@ -231,10 +231,12 @@ impl<'tcx, Prov: Provenance> PlaceTy<'tcx, Prov> {
231231 #[ inline( always) ]
232232 pub fn as_mplace_or_local (
233233 & self ,
234- ) -> Either < MPlaceTy < ' tcx , Prov > , ( mir:: Local , Option < Size > , usize ) > {
234+ ) -> Either < MPlaceTy < ' tcx , Prov > , ( mir:: Local , Option < Size > , usize , TyAndLayout < ' tcx > ) > {
235235 match self . place {
236236 Place :: Ptr ( mplace) => Left ( MPlaceTy { mplace, layout : self . layout } ) ,
237- Place :: Local { local, offset, locals_addr } => Right ( ( local, offset, locals_addr) ) ,
237+ Place :: Local { local, offset, locals_addr } => {
238+ Right ( ( local, offset, locals_addr, self . layout ) )
239+ }
238240 }
239241 }
240242
@@ -277,7 +279,7 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for PlaceTy<'tcx, Prov> {
277279 ) -> InterpResult < ' tcx , Self > {
278280 Ok ( match self . as_mplace_or_local ( ) {
279281 Left ( mplace) => mplace. offset_with_meta ( offset, mode, meta, layout, ecx) ?. into ( ) ,
280- Right ( ( local, old_offset, locals_addr) ) => {
282+ Right ( ( local, old_offset, locals_addr, _ ) ) => {
281283 debug_assert ! ( layout. is_sized( ) , "unsized locals should live in memory" ) ;
282284 assert_matches ! ( meta, MemPlaceMeta :: None ) ; // we couldn't store it anyway...
283285 // `Place::Local` are always in-bounds of their surrounding local, so we can just
@@ -328,9 +330,7 @@ impl<'tcx, Prov: Provenance> OpTy<'tcx, Prov> {
328330
329331/// The `Weiteable` trait describes interpreter values that can be written to.
330332pub trait Writeable < ' tcx , Prov : Provenance > : Projectable < ' tcx , Prov > {
331- fn as_mplace_or_local (
332- & self ,
333- ) -> Either < MPlaceTy < ' tcx , Prov > , ( mir:: Local , Option < Size > , usize , TyAndLayout < ' tcx > ) > ;
333+ fn to_place ( & self ) -> PlaceTy < ' tcx , Prov > ;
334334
335335 fn force_mplace < M : Machine < ' tcx , Provenance = Prov > > (
336336 & self ,
@@ -340,11 +340,8 @@ pub trait Writeable<'tcx, Prov: Provenance>: Projectable<'tcx, Prov> {
340340
341341impl < ' tcx , Prov : Provenance > Writeable < ' tcx , Prov > for PlaceTy < ' tcx , Prov > {
342342 #[ inline( always) ]
343- fn as_mplace_or_local (
344- & self ,
345- ) -> Either < MPlaceTy < ' tcx , Prov > , ( mir:: Local , Option < Size > , usize , TyAndLayout < ' tcx > ) > {
346- self . as_mplace_or_local ( )
347- . map_right ( |( local, offset, locals_addr) | ( local, offset, locals_addr, self . layout ) )
343+ fn to_place ( & self ) -> PlaceTy < ' tcx , Prov > {
344+ self . clone ( )
348345 }
349346
350347 #[ inline( always) ]
@@ -358,10 +355,8 @@ impl<'tcx, Prov: Provenance> Writeable<'tcx, Prov> for PlaceTy<'tcx, Prov> {
358355
359356impl < ' tcx , Prov : Provenance > Writeable < ' tcx , Prov > for MPlaceTy < ' tcx , Prov > {
360357 #[ inline( always) ]
361- fn as_mplace_or_local (
362- & self ,
363- ) -> Either < MPlaceTy < ' tcx , Prov > , ( mir:: Local , Option < Size > , usize , TyAndLayout < ' tcx > ) > {
364- Left ( self . clone ( ) )
358+ fn to_place ( & self ) -> PlaceTy < ' tcx , Prov > {
359+ self . clone ( ) . into ( )
365360 }
366361
367362 #[ inline( always) ]
@@ -615,7 +610,7 @@ where
615610
616611 // See if we can avoid an allocation. This is the counterpart to `read_immediate_raw`,
617612 // but not factored as a separate function.
618- let mplace = match dest. as_mplace_or_local ( ) {
613+ let mplace = match dest. to_place ( ) . as_mplace_or_local ( ) {
619614 Right ( ( local, offset, locals_addr, layout) ) => {
620615 if offset. is_some ( ) {
621616 // This has been projected to a part of this local. We could have complicated
@@ -728,7 +723,7 @@ where
728723 & mut self ,
729724 dest : & impl Writeable < ' tcx , M :: Provenance > ,
730725 ) -> InterpResult < ' tcx > {
731- let mplace = match dest. as_mplace_or_local ( ) {
726+ let mplace = match dest. to_place ( ) . as_mplace_or_local ( ) {
732727 Left ( mplace) => mplace,
733728 Right ( ( local, offset, locals_addr, layout) ) => {
734729 if offset. is_some ( ) {
0 commit comments