@@ -724,10 +724,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
724
724
let frame =
725
725
self . stack_mut ( ) . pop ( ) . expect ( "tried to pop a stack frame, but there were none" ) ;
726
726
727
- if let Some ( return_place ) = frame . return_place {
727
+ if !unwinding {
728
728
// Copy the return value to the caller's stack frame.
729
- let op = self . access_local ( & frame, mir:: RETURN_PLACE , None ) ?;
730
- self . copy_op ( op, return_place) ?;
729
+ if let Some ( return_place) = frame. return_place {
730
+ let op = self . access_local ( & frame, mir:: RETURN_PLACE , None ) ?;
731
+ self . copy_op ( op, return_place) ?;
732
+ } else {
733
+ throw_ub ! ( Unreachable ) ;
734
+ }
731
735
}
732
736
733
737
// Now where do we jump next?
@@ -768,25 +772,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
768
772
self . unwind_to_block ( unwind) ;
769
773
} else {
770
774
// Follow the normal return edge.
771
- // Validate the return value. Do this after deallocating so that we catch dangling
772
- // references.
773
- if let Some ( return_place) = return_place {
774
- if M :: enforce_validity ( self ) {
775
- // Data got changed, better make sure it matches the type!
776
- // It is still possible that the return place held invalid data while
777
- // the function is running, but that's okay because nobody could have
778
- // accessed that same data from the "outside" to observe any broken
779
- // invariant -- that is, unless a function somehow has a ptr to
780
- // its return place... but the way MIR is currently generated, the
781
- // return place is always a local and then this cannot happen.
782
- self . validate_operand ( self . place_to_op ( return_place) ?) ?;
783
- }
784
- } else {
785
- // Uh, that shouldn't happen... the function did not intend to return
786
- throw_ub ! ( Unreachable ) ;
787
- }
788
-
789
- // Jump to new block -- *after* validation so that the spans make more sense.
790
775
if let Some ( ret) = next_block {
791
776
self . return_to_block ( ret) ?;
792
777
}
0 commit comments