@@ -143,7 +143,7 @@ pub enum StackPopUnwind {
143
143
NotAllowed ,
144
144
}
145
145
146
- #[ derive( Clone , Eq , PartialEq , Debug , HashStable ) ] // Miri debug-prints these
146
+ #[ derive( Clone , Copy , Eq , PartialEq , Debug , HashStable ) ] // Miri debug-prints these
147
147
pub enum StackPopCleanup {
148
148
/// Jump to the next block in the caller, or cause UB if None (that's a function
149
149
/// 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> {
815
815
// Usually we want to clean up (deallocate locals), but in a few rare cases we don't.
816
816
// In that case, we return early. We also avoid validation in that case,
817
817
// 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 ) => (
820
821
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" )
827
826
}
828
- } else {
829
- ret
830
827
} ) ,
831
828
) ,
832
- StackPopCleanup :: None { cleanup, .. } => ( cleanup, None ) ,
829
+ ( StackPopCleanup :: None { cleanup, .. } , _ ) => ( cleanup, None ) ,
833
830
} ;
834
831
835
832
if !cleanup {
0 commit comments