@@ -548,8 +548,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
548
548
/// This can fail to provide an answer for extern types.
549
549
pub ( super ) fn size_and_align_of (
550
550
& self ,
551
- metadata : MemPlaceMeta < M :: PointerTag > ,
552
- layout : TyAndLayout < ' tcx > ,
551
+ metadata : & MemPlaceMeta < M :: PointerTag > ,
552
+ layout : & TyAndLayout < ' tcx > ,
553
553
) -> InterpResult < ' tcx , Option < ( Size , Align ) > > {
554
554
if !layout. is_unsized ( ) {
555
555
return Ok ( Some ( ( layout. size , layout. align . abi ) ) ) ;
@@ -577,24 +577,25 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
577
577
// the last field). Can't have foreign types here, how would we
578
578
// adjust alignment and size for them?
579
579
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
+ }
595
597
}
596
- }
597
- } ;
598
+ } ;
598
599
599
600
// FIXME (#26403, #27023): We should be adding padding
600
601
// to `sized_size` (to accommodate the `unsized_align`
@@ -645,24 +646,24 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
645
646
#[ inline]
646
647
pub fn size_and_align_of_mplace (
647
648
& self ,
648
- mplace : MPlaceTy < ' tcx , M :: PointerTag > ,
649
+ mplace : & MPlaceTy < ' tcx , M :: PointerTag > ,
649
650
) -> 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 )
651
652
}
652
653
653
654
pub fn push_stack_frame (
654
655
& mut self ,
655
656
instance : ty:: Instance < ' tcx > ,
656
657
body : & ' mir mir:: Body < ' tcx > ,
657
- return_place : Option < PlaceTy < ' tcx , M :: PointerTag > > ,
658
+ return_place : Option < & PlaceTy < ' tcx , M :: PointerTag > > ,
658
659
return_to_block : StackPopCleanup ,
659
660
) -> InterpResult < ' tcx > {
660
661
// first push a stack frame so we have access to the local substs
661
662
let pre_frame = Frame {
662
663
body,
663
664
loc : Err ( body. span ) , // Span used for errors caused during preamble.
664
665
return_to_block,
665
- return_place,
666
+ return_place : return_place . copied ( ) ,
666
667
// empty local array, we fill it in below, after we are inside the stack frame and
667
668
// all methods actually know about the frame
668
669
locals : IndexVec :: new ( ) ,
@@ -777,10 +778,10 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
777
778
778
779
if !unwinding {
779
780
// 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 {
781
782
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) ) ;
784
785
} else {
785
786
throw_ub ! ( Unreachable ) ;
786
787
}
0 commit comments