@@ -21,21 +21,24 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
2121 ast_block : & ' tcx hir:: Block ,
2222 source_info : SourceInfo )
2323 -> BlockAnd < ( ) > {
24- let Block { extent, span, stmts, expr, targeted_by_break } = self . hir . mirror ( ast_block) ;
25- self . in_scope ( extent, block, move |this| {
26- if targeted_by_break {
27- // This is a `break`-able block (currently only `catch { ... }`)
28- let exit_block = this. cfg . start_new_block ( ) ;
29- let block_exit = this. in_breakable_scope ( None , exit_block,
30- destination. clone ( ) , |this| {
24+ let Block { extent, opt_destruction_extent, span, stmts, expr, targeted_by_break } =
25+ self . hir . mirror ( ast_block) ;
26+ self . in_opt_scope ( opt_destruction_extent, block, move |this| {
27+ this. in_scope ( extent, block, move |this| {
28+ if targeted_by_break {
29+ // This is a `break`-able block (currently only `catch { ... }`)
30+ let exit_block = this. cfg . start_new_block ( ) ;
31+ let block_exit = this. in_breakable_scope (
32+ None , exit_block, destination. clone ( ) , |this| {
33+ this. ast_block_stmts ( destination, block, span, stmts, expr)
34+ } ) ;
35+ this. cfg . terminate ( unpack ! ( block_exit) , source_info,
36+ TerminatorKind :: Goto { target : exit_block } ) ;
37+ exit_block. unit ( )
38+ } else {
3139 this. ast_block_stmts ( destination, block, span, stmts, expr)
32- } ) ;
33- this. cfg . terminate ( unpack ! ( block_exit) , source_info,
34- TerminatorKind :: Goto { target : exit_block } ) ;
35- exit_block. unit ( )
36- } else {
37- this. ast_block_stmts ( destination, block, span, stmts, expr)
38- }
40+ }
41+ } )
3942 } )
4043 }
4144
@@ -67,12 +70,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
6770 let mut let_extent_stack = Vec :: with_capacity ( 8 ) ;
6871 let outer_visibility_scope = this. visibility_scope ;
6972 for stmt in stmts {
70- let Stmt { span : _, kind } = this. hir . mirror ( stmt) ;
73+ let Stmt { span : _, kind, opt_destruction_extent } = this. hir . mirror ( stmt) ;
7174 match kind {
7275 StmtKind :: Expr { scope, expr } => {
73- unpack ! ( block = this. in_scope( scope, block, |this| {
74- let expr = this. hir. mirror( expr) ;
75- this. stmt_expr( block, expr)
76+ unpack ! ( block = this. in_opt_scope( opt_destruction_extent, block, |this| {
77+ this. in_scope( scope, block, |this| {
78+ let expr = this. hir. mirror( expr) ;
79+ this. stmt_expr( block, expr)
80+ } )
7681 } ) ) ;
7782 }
7883 StmtKind :: Let { remainder_scope, init_scope, pattern, initializer } => {
@@ -89,10 +94,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
8994
9095 // Evaluate the initializer, if present.
9196 if let Some ( init) = initializer {
92- unpack ! ( block = this. in_scope( init_scope, block, move |this| {
93- // FIXME #30046 ^~~~
94- this. expr_into_pattern( block, pattern, init)
95- } ) ) ;
97+ unpack ! ( block = this. in_opt_scope(
98+ opt_destruction_extent, block, move |this| {
99+ this. in_scope( init_scope, block, move |this| {
100+ // FIXME #30046 ^~~~
101+ this. expr_into_pattern( block, pattern, init)
102+ } )
103+ } ) ) ;
96104 } else {
97105 this. visit_bindings ( & pattern, & mut |this, _, _, node, span, _| {
98106 this. storage_live_binding ( block, node, span) ;
0 commit comments