@@ -548,8 +548,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
548548 /// This can fail to provide an answer for extern types.
549549 pub ( super ) fn size_and_align_of (
550550 & self ,
551- metadata : MemPlaceMeta < M :: PointerTag > ,
552- layout : TyAndLayout < ' tcx > ,
551+ metadata : & MemPlaceMeta < M :: PointerTag > ,
552+ layout : & TyAndLayout < ' tcx > ,
553553 ) -> InterpResult < ' tcx , Option < ( Size , Align ) > > {
554554 if !layout. is_unsized ( ) {
555555 return Ok ( Some ( ( layout. size , layout. align . abi ) ) ) ;
@@ -577,24 +577,25 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
577577 // the last field). Can't have foreign types here, how would we
578578 // adjust alignment and size for them?
579579 let field = layout. field ( self , layout. fields . count ( ) - 1 ) ?;
580- let ( unsized_size, unsized_align) = match self . size_and_align_of ( metadata, field) ? {
581- Some ( size_and_align) => size_and_align,
582- None => {
583- // A field with extern type. If this field is at offset 0, we behave
584- // like the underlying extern type.
585- // FIXME: Once we have made decisions for how to handle size and alignment
586- // of `extern type`, this should be adapted. It is just a temporary hack
587- // to get some code to work that probably ought to work.
588- if sized_size == Size :: ZERO {
589- return Ok ( None ) ;
590- } else {
591- span_bug ! (
592- self . cur_span( ) ,
593- "Fields cannot be extern types, unless they are at offset 0"
594- )
580+ let ( unsized_size, unsized_align) =
581+ match self . size_and_align_of ( metadata, & field) ? {
582+ Some ( size_and_align) => size_and_align,
583+ None => {
584+ // A field with extern type. If this field is at offset 0, we behave
585+ // like the underlying extern type.
586+ // FIXME: Once we have made decisions for how to handle size and alignment
587+ // of `extern type`, this should be adapted. It is just a temporary hack
588+ // to get some code to work that probably ought to work.
589+ if sized_size == Size :: ZERO {
590+ return Ok ( None ) ;
591+ } else {
592+ span_bug ! (
593+ self . cur_span( ) ,
594+ "Fields cannot be extern types, unless they are at offset 0"
595+ )
596+ }
595597 }
596- }
597- } ;
598+ } ;
598599
599600 // FIXME (#26403, #27023): We should be adding padding
600601 // to `sized_size` (to accommodate the `unsized_align`
@@ -645,24 +646,24 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
645646 #[ inline]
646647 pub fn size_and_align_of_mplace (
647648 & self ,
648- mplace : MPlaceTy < ' tcx , M :: PointerTag > ,
649+ mplace : & MPlaceTy < ' tcx , M :: PointerTag > ,
649650 ) -> InterpResult < ' tcx , Option < ( Size , Align ) > > {
650- self . size_and_align_of ( mplace. meta , mplace. layout )
651+ self . size_and_align_of ( & mplace. meta , & mplace. layout )
651652 }
652653
653654 pub fn push_stack_frame (
654655 & mut self ,
655656 instance : ty:: Instance < ' tcx > ,
656657 body : & ' mir mir:: Body < ' tcx > ,
657- return_place : Option < PlaceTy < ' tcx , M :: PointerTag > > ,
658+ return_place : Option < & PlaceTy < ' tcx , M :: PointerTag > > ,
658659 return_to_block : StackPopCleanup ,
659660 ) -> InterpResult < ' tcx > {
660661 // first push a stack frame so we have access to the local substs
661662 let pre_frame = Frame {
662663 body,
663664 loc : Err ( body. span ) , // Span used for errors caused during preamble.
664665 return_to_block,
665- return_place,
666+ return_place : return_place . copied ( ) ,
666667 // empty local array, we fill it in below, after we are inside the stack frame and
667668 // all methods actually know about the frame
668669 locals : IndexVec :: new ( ) ,
@@ -777,10 +778,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
777778
778779 if !unwinding {
779780 // Copy the return value to the caller's stack frame.
780- if let Some ( return_place) = frame. return_place {
781+ if let Some ( ref return_place) = frame. return_place {
781782 let op = self . access_local ( & frame, mir:: RETURN_PLACE , None ) ?;
782- self . copy_op_transmute ( op, return_place) ?;
783- trace ! ( "{:?}" , self . dump_place( * return_place) ) ;
783+ self . copy_op_transmute ( & op, return_place) ?;
784+ trace ! ( "{:?}" , self . dump_place( * * return_place) ) ;
784785 } else {
785786 throw_ub ! ( Unreachable ) ;
786787 }
0 commit comments