@@ -317,11 +317,6 @@ struct Builder<'a, 'tcx> {
317317
318318 var_debug_info : Vec < VarDebugInfo < ' tcx > > ,
319319
320- /// Cached block with the `RESUME` terminator; this is created
321- /// when first set of cleanups are built.
322- cached_resume_block : Option < BasicBlock > ,
323- /// Cached block with the `RETURN` terminator.
324- cached_return_block : Option < BasicBlock > ,
325320 /// Cached block with the `UNREACHABLE` terminator.
326321 cached_unreachable_block : Option < BasicBlock > ,
327322}
@@ -583,50 +578,34 @@ where
583578 region:: Scope { id : body. value . hir_id . local_id , data : region:: ScopeData :: CallSite } ;
584579 let arg_scope =
585580 region:: Scope { id : body. value . hir_id . local_id , data : region:: ScopeData :: Arguments } ;
586- let mut block = START_BLOCK ;
587581 let source_info = builder. source_info ( span) ;
588582 let call_site_s = ( call_site_scope, source_info) ;
589- unpack ! (
590- block = builder. in_scope( call_site_s, LintLevel :: Inherited , |builder| {
591- if should_abort_on_panic( tcx, fn_def_id, abi) {
592- builder. schedule_abort( ) ;
593- }
594-
595- let arg_scope_s = ( arg_scope, source_info) ;
596- // `return_block` is called when we evaluate a `return` expression, so
597- // we just use `START_BLOCK` here.
598- unpack!(
599- block = builder. in_breakable_scope(
600- None ,
601- START_BLOCK ,
602- Place :: return_place( ) ,
603- |builder| {
604- builder. in_scope( arg_scope_s, LintLevel :: Inherited , |builder| {
605- builder. args_and_body(
606- block,
607- fn_def_id,
608- & arguments,
609- arg_scope,
610- & body. value,
611- )
612- } )
613- } ,
614- )
615- ) ;
616- // Attribute epilogue to function's closing brace
617- let fn_end = span. shrink_to_hi( ) ;
618- let source_info = builder. source_info( fn_end) ;
619- let return_block = builder. return_block( ) ;
620- builder. cfg. goto( block, source_info, return_block) ;
621- builder. cfg. terminate( return_block, source_info, TerminatorKind :: Return ) ;
622- // Attribute any unreachable codepaths to the function's closing brace
623- if let Some ( unreachable_block) = builder. cached_unreachable_block {
624- builder. cfg. terminate( unreachable_block, source_info, TerminatorKind :: Unreachable ) ;
625- }
626- return_block. unit( )
627- } )
628- ) ;
629- assert_eq ! ( block, builder. return_block( ) ) ;
583+ unpack ! ( builder. in_scope( call_site_s, LintLevel :: Inherited , |builder| {
584+ let arg_scope_s = ( arg_scope, source_info) ;
585+ // Attribute epilogue to function's closing brace
586+ let fn_end = span. shrink_to_hi( ) ;
587+ let return_block =
588+ unpack!( builder. in_breakable_scope( None , Place :: return_place( ) , fn_end, |builder| {
589+ Some ( builder. in_scope( arg_scope_s, LintLevel :: Inherited , |builder| {
590+ builder. args_and_body(
591+ START_BLOCK ,
592+ fn_def_id,
593+ & arguments,
594+ arg_scope,
595+ & body. value,
596+ )
597+ } ) )
598+ } , ) ) ;
599+ let source_info = builder. source_info( fn_end) ;
600+ builder. cfg. terminate( return_block, source_info, TerminatorKind :: Return ) ;
601+ let should_abort = should_abort_on_panic( tcx, fn_def_id, abi) ;
602+ builder. build_drop_trees( should_abort) ;
603+ // Attribute any unreachable codepaths to the function's closing brace
604+ if let Some ( unreachable_block) = builder. cached_unreachable_block {
605+ builder. cfg. terminate( unreachable_block, source_info, TerminatorKind :: Unreachable ) ;
606+ }
607+ return_block. unit( )
608+ } ) ) ;
630609
631610 let mut spread_arg = None ;
632611 if abi == Abi :: RustCall {
@@ -659,9 +638,6 @@ fn construct_const<'a, 'tcx>(
659638 let source_info = builder. source_info ( span) ;
660639 builder. cfg . terminate ( block, source_info, TerminatorKind :: Return ) ;
661640
662- // Constants can't `return` so a return block should not be created.
663- assert_eq ! ( builder. cached_return_block, None ) ;
664-
665641 // Constants may be match expressions in which case an unreachable block may
666642 // be created, so terminate it properly.
667643 if let Some ( unreachable_block) = builder. cached_unreachable_block {
@@ -735,7 +711,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
735711 fn_span : span,
736712 arg_count,
737713 generator_kind,
738- scopes : Default :: default ( ) ,
714+ scopes : scope :: Scopes :: new ( is_generator ) ,
739715 block_context : BlockContext :: new ( ) ,
740716 source_scopes : IndexVec :: new ( ) ,
741717 source_scope : OUTERMOST_SOURCE_SCOPE ,
@@ -751,8 +727,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
751727 var_indices : Default :: default ( ) ,
752728 unit_temp : None ,
753729 var_debug_info : vec ! [ ] ,
754- cached_resume_block : None ,
755- cached_return_block : None ,
756730 cached_unreachable_block : None ,
757731 } ;
758732
@@ -997,17 +971,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
997971 }
998972 }
999973 }
1000-
1001- fn return_block ( & mut self ) -> BasicBlock {
1002- match self . cached_return_block {
1003- Some ( rb) => rb,
1004- None => {
1005- let rb = self . cfg . start_new_block ( ) ;
1006- self . cached_return_block = Some ( rb) ;
1007- rb
1008- }
1009- }
1010- }
1011974}
1012975
1013976///////////////////////////////////////////////////////////////////////////
0 commit comments