@@ -13,42 +13,33 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1313 ast_block : BlockId ,
1414 source_info : SourceInfo ,
1515 ) -> 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] ;
2518 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 (
4223 destination,
4324 block,
4425 span,
4526 & stmts,
4627 expr,
4728 safety_mode,
4829 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+ }
5243 } )
5344 }
5445
@@ -92,20 +83,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
9283
9384 let source_info = this. source_info ( span) ;
9485 for stmt in stmts {
95- let Stmt { ref kind, opt_destruction_scope } = this. thir [ * stmt] ;
86+ let Stmt { ref kind } = this. thir [ * stmt] ;
9687 match kind {
9788 StmtKind :: Expr { scope, expr } => {
9889 this. block_context . push ( BlockFrame :: Statement { ignores_expr_result : true } ) ;
90+ let si = ( * scope, source_info) ;
9991 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+ } )
10995 ) ;
11096 }
11197 StmtKind :: Let {
@@ -221,43 +207,38 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
221207
222208 let init = & this. thir [ * initializer] ;
223209 let initializer_span = init. span ;
210+ let scope = ( * init_scope, source_info) ;
224211 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(
251225 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+ } )
261242 ) ;
262243 this. cfg . goto ( failure, source_info, failure_entry) ;
263244
@@ -298,25 +279,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
298279 if let Some ( init) = initializer {
299280 let init = & this. thir [ * init] ;
300281 let initializer_span = init. span ;
282+ let scope = ( * init_scope, source_info) ;
301283
302284 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+ } )
320296 )
321297 } else {
322298 let scope = ( * init_scope, source_info) ;
0 commit comments