@@ -13,42 +13,33 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
13
13
ast_block : BlockId ,
14
14
source_info : SourceInfo ,
15
15
) -> BlockAnd < ( ) > {
16
- let Block {
17
- region_scope,
18
- opt_destruction_scope,
19
- span,
20
- ref stmts,
21
- expr,
22
- targeted_by_break,
23
- safety_mode,
24
- } = self . thir [ ast_block] ;
16
+ let Block { region_scope, span, ref stmts, expr, targeted_by_break, safety_mode } =
17
+ self . thir [ ast_block] ;
25
18
let expr = expr. map ( |expr| & self . thir [ expr] ) ;
26
- self . in_opt_scope ( opt_destruction_scope. map ( |de| ( de, source_info) ) , move |this| {
27
- this. in_scope ( ( region_scope, source_info) , LintLevel :: Inherited , move |this| {
28
- if targeted_by_break {
29
- this. in_breakable_scope ( None , destination, span, |this| {
30
- Some ( this. ast_block_stmts (
31
- destination,
32
- block,
33
- span,
34
- stmts,
35
- expr,
36
- safety_mode,
37
- region_scope,
38
- ) )
39
- } )
40
- } else {
41
- this. ast_block_stmts (
19
+ self . in_scope ( ( region_scope, source_info) , LintLevel :: Inherited , move |this| {
20
+ if targeted_by_break {
21
+ this. in_breakable_scope ( None , destination, span, |this| {
22
+ Some ( this. ast_block_stmts (
42
23
destination,
43
24
block,
44
25
span,
45
26
stmts,
46
27
expr,
47
28
safety_mode,
48
29
region_scope,
49
- )
50
- }
51
- } )
30
+ ) )
31
+ } )
32
+ } else {
33
+ this. ast_block_stmts (
34
+ destination,
35
+ block,
36
+ span,
37
+ stmts,
38
+ expr,
39
+ safety_mode,
40
+ region_scope,
41
+ )
42
+ }
52
43
} )
53
44
}
54
45
@@ -92,20 +83,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
92
83
93
84
let source_info = this. source_info ( span) ;
94
85
for stmt in stmts {
95
- let Stmt { ref kind, opt_destruction_scope } = this. thir [ * stmt] ;
86
+ let Stmt { ref kind } = this. thir [ * stmt] ;
96
87
match kind {
97
88
StmtKind :: Expr { scope, expr } => {
98
89
this. block_context . push ( BlockFrame :: Statement { ignores_expr_result : true } ) ;
90
+ let si = ( * scope, source_info) ;
99
91
unpack ! (
100
- block = this. in_opt_scope(
101
- opt_destruction_scope. map( |de| ( de, source_info) ) ,
102
- |this| {
103
- let si = ( * scope, source_info) ;
104
- this. in_scope( si, LintLevel :: Inherited , |this| {
105
- this. stmt_expr( block, & this. thir[ * expr] , Some ( * scope) )
106
- } )
107
- }
108
- )
92
+ block = this. in_scope( si, LintLevel :: Inherited , |this| {
93
+ this. stmt_expr( block, & this. thir[ * expr] , Some ( * scope) )
94
+ } )
109
95
) ;
110
96
}
111
97
StmtKind :: Let {
@@ -221,43 +207,38 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
221
207
222
208
let init = & this. thir [ * initializer] ;
223
209
let initializer_span = init. span ;
210
+ let scope = ( * init_scope, source_info) ;
224
211
let failure = unpack ! (
225
- block = this. in_opt_scope(
226
- opt_destruction_scope. map( |de| ( de, source_info) ) ,
227
- |this| {
228
- let scope = ( * init_scope, source_info) ;
229
- this. in_scope( scope, * lint_level, |this| {
230
- this. declare_bindings(
231
- visibility_scope,
232
- remainder_span,
233
- pattern,
234
- None ,
235
- Some ( ( Some ( & destination) , initializer_span) ) ,
236
- ) ;
237
- this. visit_primary_bindings(
238
- pattern,
239
- UserTypeProjections :: none( ) ,
240
- & mut |this, _, _, _, node, span, _, _| {
241
- this. storage_live_binding(
242
- block,
243
- node,
244
- span,
245
- OutsideGuard ,
246
- true ,
247
- ) ;
248
- } ,
249
- ) ;
250
- this. ast_let_else(
212
+ block = this. in_scope( scope, * lint_level, |this| {
213
+ this. declare_bindings(
214
+ visibility_scope,
215
+ remainder_span,
216
+ pattern,
217
+ None ,
218
+ Some ( ( Some ( & destination) , initializer_span) ) ,
219
+ ) ;
220
+ this. visit_primary_bindings(
221
+ pattern,
222
+ UserTypeProjections :: none( ) ,
223
+ & mut |this, _, _, _, node, span, _, _| {
224
+ this. storage_live_binding(
251
225
block,
252
- init,
253
- initializer_span,
254
- * else_block,
255
- & last_remainder_scope,
256
- pattern,
257
- )
258
- } )
259
- }
260
- )
226
+ node,
227
+ span,
228
+ OutsideGuard ,
229
+ true ,
230
+ ) ;
231
+ } ,
232
+ ) ;
233
+ this. ast_let_else(
234
+ block,
235
+ init,
236
+ initializer_span,
237
+ * else_block,
238
+ & last_remainder_scope,
239
+ pattern,
240
+ )
241
+ } )
261
242
) ;
262
243
this. cfg . goto ( failure, source_info, failure_entry) ;
263
244
@@ -298,25 +279,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
298
279
if let Some ( init) = initializer {
299
280
let init = & this. thir [ * init] ;
300
281
let initializer_span = init. span ;
282
+ let scope = ( * init_scope, source_info) ;
301
283
302
284
unpack ! (
303
- block = this. in_opt_scope(
304
- opt_destruction_scope. map( |de| ( de, source_info) ) ,
305
- |this| {
306
- let scope = ( * init_scope, source_info) ;
307
- this. in_scope( scope, * lint_level, |this| {
308
- this. declare_bindings(
309
- visibility_scope,
310
- remainder_span,
311
- pattern,
312
- None ,
313
- Some ( ( None , initializer_span) ) ,
314
- ) ;
315
- this. expr_into_pattern( block, pattern, init)
316
- // irrefutable pattern
317
- } )
318
- } ,
319
- )
285
+ block = this. in_scope( scope, * lint_level, |this| {
286
+ this. declare_bindings(
287
+ visibility_scope,
288
+ remainder_span,
289
+ pattern,
290
+ None ,
291
+ Some ( ( None , initializer_span) ) ,
292
+ ) ;
293
+ this. expr_into_pattern( block, & pattern, init)
294
+ // irrefutable pattern
295
+ } )
320
296
)
321
297
} else {
322
298
let scope = ( * init_scope, source_info) ;
0 commit comments