@@ -231,10 +231,12 @@ impl<'tcx, Prov: Provenance> PlaceTy<'tcx, Prov> {
231
231
#[ inline( always) ]
232
232
pub fn as_mplace_or_local (
233
233
& self ,
234
- ) -> Either < MPlaceTy < ' tcx , Prov > , ( mir:: Local , Option < Size > , usize ) > {
234
+ ) -> Either < MPlaceTy < ' tcx , Prov > , ( mir:: Local , Option < Size > , usize , TyAndLayout < ' tcx > ) > {
235
235
match self . place {
236
236
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
+ }
238
240
}
239
241
}
240
242
@@ -277,7 +279,7 @@ impl<'tcx, Prov: Provenance> Projectable<'tcx, Prov> for PlaceTy<'tcx, Prov> {
277
279
) -> InterpResult < ' tcx , Self > {
278
280
Ok ( match self . as_mplace_or_local ( ) {
279
281
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, _ ) ) => {
281
283
debug_assert ! ( layout. is_sized( ) , "unsized locals should live in memory" ) ;
282
284
assert_matches ! ( meta, MemPlaceMeta :: None ) ; // we couldn't store it anyway...
283
285
// `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> {
328
330
329
331
/// The `Weiteable` trait describes interpreter values that can be written to.
330
332
pub 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 > ;
334
334
335
335
fn force_mplace < M : Machine < ' tcx , Provenance = Prov > > (
336
336
& self ,
@@ -340,11 +340,8 @@ pub trait Writeable<'tcx, Prov: Provenance>: Projectable<'tcx, Prov> {
340
340
341
341
impl < ' tcx , Prov : Provenance > Writeable < ' tcx , Prov > for PlaceTy < ' tcx , Prov > {
342
342
#[ 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 ( )
348
345
}
349
346
350
347
#[ inline( always) ]
@@ -358,10 +355,8 @@ impl<'tcx, Prov: Provenance> Writeable<'tcx, Prov> for PlaceTy<'tcx, Prov> {
358
355
359
356
impl < ' tcx , Prov : Provenance > Writeable < ' tcx , Prov > for MPlaceTy < ' tcx , Prov > {
360
357
#[ 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 ( )
365
360
}
366
361
367
362
#[ inline( always) ]
@@ -613,7 +608,7 @@ where
613
608
614
609
// See if we can avoid an allocation. This is the counterpart to `read_immediate_raw`,
615
610
// but not factored as a separate function.
616
- let mplace = match dest. as_mplace_or_local ( ) {
611
+ let mplace = match dest. to_place ( ) . as_mplace_or_local ( ) {
617
612
Right ( ( local, offset, locals_addr, layout) ) => {
618
613
if offset. is_some ( ) {
619
614
// This has been projected to a part of this local. We could have complicated
@@ -726,7 +721,7 @@ where
726
721
& mut self ,
727
722
dest : & impl Writeable < ' tcx , M :: Provenance > ,
728
723
) -> InterpResult < ' tcx > {
729
- let mplace = match dest. as_mplace_or_local ( ) {
724
+ let mplace = match dest. to_place ( ) . as_mplace_or_local ( ) {
730
725
Left ( mplace) => mplace,
731
726
Right ( ( local, offset, locals_addr, layout) ) => {
732
727
if offset. is_some ( ) {
0 commit comments