@@ -156,11 +156,11 @@ pub enum StackPopCleanup {
156156 /// `ret` stores the block we jump to on a normal return, while `unwind`
157157 /// stores the block used for cleanup during unwinding.
158158 Goto { ret : Option < mir:: BasicBlock > , unwind : StackPopUnwind } ,
159- /// Just do nothing: Used by Main and for TLS hooks in miri .
159+ /// The root frame of the stack: nowhere else to jump to .
160160 /// `cleanup` says whether locals are deallocated. Static computation
161161 /// wants them leaked to intern what they need (and just throw away
162162 /// the entire `ecx` when it is done).
163- None { cleanup : bool } ,
163+ Root { cleanup : bool } ,
164164}
165165
166166/// State of a local variable including a memoized layout
@@ -849,7 +849,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
849849 // because this is CTFE and the final value will be thoroughly validated anyway.
850850 let cleanup = match return_to_block {
851851 StackPopCleanup :: Goto { .. } => true ,
852- StackPopCleanup :: None { cleanup, .. } => cleanup,
852+ StackPopCleanup :: Root { cleanup, .. } => cleanup,
853853 } ;
854854
855855 if !cleanup {
@@ -874,16 +874,22 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
874874 // Follow the unwind edge.
875875 let unwind = match return_to_block {
876876 StackPopCleanup :: Goto { unwind, .. } => unwind,
877- StackPopCleanup :: None { .. } => {
878- panic ! ( "Encountered StackPopCleanup::None when unwinding!" )
877+ StackPopCleanup :: Root { .. } => {
878+ panic ! ( "encountered StackPopCleanup::Root when unwinding!" )
879879 }
880880 } ;
881881 self . unwind_to_block ( unwind)
882882 } else {
883883 // Follow the normal return edge.
884884 match return_to_block {
885885 StackPopCleanup :: Goto { ret, .. } => self . return_to_block ( ret) ,
886- StackPopCleanup :: None { .. } => Ok ( ( ) ) ,
886+ StackPopCleanup :: Root { .. } => {
887+ assert ! (
888+ self . stack( ) . is_empty( ) ,
889+ "only the topmost frame can have StackPopCleanup::Root"
890+ ) ;
891+ Ok ( ( ) )
892+ }
887893 }
888894 }
889895 }
0 commit comments