@@ -492,23 +492,6 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
492492 let frame = self . stack . pop ( ) . expect (
493493 "tried to pop a stack frame, but there were none" ,
494494 ) ;
495- match frame. return_to_block {
496- StackPopCleanup :: Goto ( block) => {
497- self . goto_block ( block) ?;
498- }
499- StackPopCleanup :: None { cleanup } => {
500- if !cleanup {
501- // Leak the locals. Also skip validation, this is only used by
502- // static/const computation which does its own (stronger) final
503- // validation.
504- return Ok ( ( ) ) ;
505- }
506- }
507- }
508- // Deallocate all locals that are backed by an allocation.
509- for local in frame. locals {
510- self . deallocate_local ( local) ?;
511- }
512495 // Validate the return value.
513496 if let Some ( return_place) = frame. return_place {
514497 if M :: enforce_validity ( self ) {
@@ -530,6 +513,22 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
530513 // Uh, that shouldn't happen... the function did not intend to return
531514 return err ! ( Unreachable ) ;
532515 }
516+ // Jump to new block -- *after* validation so that the spans make more sense.
517+ match frame. return_to_block {
518+ StackPopCleanup :: Goto ( block) => {
519+ self . goto_block ( block) ?;
520+ }
521+ StackPopCleanup :: None { cleanup } => {
522+ if !cleanup {
523+ // Leak the locals.
524+ return Ok ( ( ) ) ;
525+ }
526+ }
527+ }
528+ // Deallocate all locals that are backed by an allocation.
529+ for local in frame. locals {
530+ self . deallocate_local ( local) ?;
531+ }
533532
534533 if self . stack . len ( ) > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc...
535534 debug ! ( "CONTINUING({}) {}" , self . cur_frame( ) , self . frame( ) . instance) ;
0 commit comments