@@ -143,7 +143,7 @@ pub enum StackPopUnwind {
143143 NotAllowed ,
144144}
145145
146- #[ derive( Clone , Eq , PartialEq , Debug , HashStable ) ] // Miri debug-prints these
146+ #[ derive( Clone , Copy , Eq , PartialEq , Debug , HashStable ) ] // Miri debug-prints these
147147pub enum StackPopCleanup {
148148 /// Jump to the next block in the caller, or cause UB if None (that's a function
149149 /// that may never return). Also store layout of return place so
@@ -815,21 +815,18 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
815815 // Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
816816 // In that case, we return early. We also avoid validation in that case,
817817 // because this is CTFE and the final value will be thoroughly validated anyway.
818- let ( cleanup, next_block) = match frame. return_to_block {
819- StackPopCleanup :: Goto { ret, unwind } => (
818+ let ( cleanup, next_block) = match ( frame. return_to_block , unwinding) {
819+ ( StackPopCleanup :: Goto { ret, .. } , false ) => ( true , Some ( ret) ) ,
820+ ( StackPopCleanup :: Goto { unwind, .. } , true ) => (
820821 true ,
821- Some ( if unwinding {
822- match unwind {
823- StackPopUnwind :: Cleanup ( unwind) => unwind,
824- StackPopUnwind :: NotAllowed => {
825- throw_ub_format ! ( "unwind past a frame that does not allow unwinding" )
826- }
822+ Some ( match unwind {
823+ StackPopUnwind :: Cleanup ( unwind) => unwind,
824+ StackPopUnwind :: NotAllowed => {
825+ throw_ub_format ! ( "unwind past a frame that does not allow unwinding" )
827826 }
828- } else {
829- ret
830827 } ) ,
831828 ) ,
832- StackPopCleanup :: None { cleanup, .. } => ( cleanup, None ) ,
829+ ( StackPopCleanup :: None { cleanup, .. } , _ ) => ( cleanup, None ) ,
833830 } ;
834831
835832 if !cleanup {
0 commit comments