@@ -21,21 +21,24 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
21
21
ast_block : & ' tcx hir:: Block ,
22
22
source_info : SourceInfo )
23
23
-> 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 {
31
39
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
+ } )
39
42
} )
40
43
}
41
44
@@ -67,12 +70,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
67
70
let mut let_extent_stack = Vec :: with_capacity ( 8 ) ;
68
71
let outer_visibility_scope = this. visibility_scope ;
69
72
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) ;
71
74
match kind {
72
75
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
+ } )
76
81
} ) ) ;
77
82
}
78
83
StmtKind :: Let { remainder_scope, init_scope, pattern, initializer } => {
@@ -89,10 +94,13 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
89
94
90
95
// Evaluate the initializer, if present.
91
96
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
+ } ) ) ;
96
104
} else {
97
105
this. visit_bindings ( & pattern, & mut |this, _, _, node, span, _| {
98
106
this. storage_live_binding ( block, node, span) ;
0 commit comments