@@ -364,12 +364,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
364
364
let arm_block = this. bind_pattern (
365
365
outer_source_info,
366
366
candidate,
367
- arm. guard . as_ref ( ) ,
368
367
& fake_borrow_temps,
369
368
scrutinee_span,
370
- Some ( arm. span ) ,
371
- Some ( arm. scope ) ,
372
- Some ( match_scope) ,
369
+ Some ( ( arm, match_scope) ) ,
373
370
false ,
374
371
) ;
375
372
@@ -410,12 +407,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
410
407
& mut self ,
411
408
outer_source_info : SourceInfo ,
412
409
candidate : Candidate < ' _ , ' tcx > ,
413
- guard : Option < & Guard < ' tcx > > ,
414
410
fake_borrow_temps : & [ ( Place < ' tcx > , Local ) ] ,
415
411
scrutinee_span : Span ,
416
- arm_span : Option < Span > ,
417
- arm_scope : Option < region:: Scope > ,
418
- match_scope : Option < region:: Scope > ,
412
+ arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
419
413
storages_alive : bool ,
420
414
) -> BasicBlock {
421
415
if candidate. subcandidates . is_empty ( ) {
@@ -424,11 +418,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
424
418
self . bind_and_guard_matched_candidate (
425
419
candidate,
426
420
& [ ] ,
427
- guard,
428
421
fake_borrow_temps,
429
422
scrutinee_span,
430
- arm_span,
431
- match_scope,
423
+ arm_match_scope,
432
424
true ,
433
425
storages_alive,
434
426
)
@@ -449,28 +441,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
449
441
// we lower the guard.
450
442
let target_block = self . cfg . start_new_block ( ) ;
451
443
let mut schedule_drops = true ;
444
+ let arm = arm_match_scope. unzip ( ) . 0 ;
452
445
// We keep a stack of all of the bindings and type ascriptions
453
446
// from the parent candidates that we visit, that also need to
454
447
// be bound for each candidate.
455
448
traverse_candidate (
456
449
candidate,
457
450
& mut Vec :: new ( ) ,
458
451
& mut |leaf_candidate, parent_bindings| {
459
- if let Some ( arm_scope ) = arm_scope {
460
- self . clear_top_scope ( arm_scope ) ;
452
+ if let Some ( arm ) = arm {
453
+ self . clear_top_scope ( arm . scope ) ;
461
454
}
462
455
let binding_end = self . bind_and_guard_matched_candidate (
463
456
leaf_candidate,
464
457
parent_bindings,
465
- guard,
466
458
& fake_borrow_temps,
467
459
scrutinee_span,
468
- arm_span,
469
- match_scope,
460
+ arm_match_scope,
470
461
schedule_drops,
471
462
storages_alive,
472
463
) ;
473
- if arm_scope . is_none ( ) {
464
+ if arm . is_none ( ) {
474
465
schedule_drops = false ;
475
466
}
476
467
self . cfg . goto ( binding_end, outer_source_info, target_block) ;
@@ -636,12 +627,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
636
627
self . bind_pattern (
637
628
self . source_info ( irrefutable_pat. span ) ,
638
629
candidate,
639
- None ,
640
630
& fake_borrow_temps,
641
631
irrefutable_pat. span ,
642
632
None ,
643
- None ,
644
- None ,
645
633
false ,
646
634
)
647
635
. unit ( )
@@ -1820,12 +1808,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1820
1808
let post_guard_block = self . bind_pattern (
1821
1809
self . source_info ( pat. span ) ,
1822
1810
guard_candidate,
1823
- None ,
1824
1811
& fake_borrow_temps,
1825
1812
expr. span ,
1826
1813
None ,
1827
- None ,
1828
- None ,
1829
1814
false ,
1830
1815
) ;
1831
1816
@@ -1844,11 +1829,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1844
1829
& mut self ,
1845
1830
candidate : Candidate < ' pat , ' tcx > ,
1846
1831
parent_bindings : & [ ( Vec < Binding < ' tcx > > , Vec < Ascription < ' tcx > > ) ] ,
1847
- guard : Option < & Guard < ' tcx > > ,
1848
1832
fake_borrows : & [ ( Place < ' tcx > , Local ) ] ,
1849
1833
scrutinee_span : Span ,
1850
- arm_span : Option < Span > ,
1851
- match_scope : Option < region:: Scope > ,
1834
+ arm_match_scope : Option < ( & Arm < ' tcx > , region:: Scope ) > ,
1852
1835
schedule_drops : bool ,
1853
1836
storages_alive : bool ,
1854
1837
) -> BasicBlock {
@@ -1960,7 +1943,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1960
1943
// the reference that we create for the arm.
1961
1944
// * So we eagerly create the reference for the arm and then take a
1962
1945
// reference to that.
1963
- if let Some ( guard) = guard {
1946
+ if let Some ( ( arm, match_scope) ) = arm_match_scope
1947
+ && let Some ( guard) = & arm. guard
1948
+ {
1964
1949
let tcx = self . tcx ;
1965
1950
let bindings = parent_bindings
1966
1951
. iter ( )
@@ -1981,8 +1966,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1981
1966
self . cfg . push_assign ( block, scrutinee_source_info, Place :: from ( temp) , borrow) ;
1982
1967
}
1983
1968
1984
- let arm_span = arm_span. unwrap ( ) ;
1985
- let match_scope = match_scope. unwrap ( ) ;
1986
1969
let mut guard_span = rustc_span:: DUMMY_SP ;
1987
1970
1988
1971
let ( post_guard_block, otherwise_post_guard_block) =
@@ -1995,13 +1978,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1995
1978
e,
1996
1979
None ,
1997
1980
match_scope,
1998
- this. source_info ( arm_span ) ,
1981
+ this. source_info ( arm . span ) ,
1999
1982
)
2000
1983
}
2001
1984
Guard :: IfLet ( ref pat, scrutinee) => {
2002
1985
let s = & this. thir [ scrutinee] ;
2003
1986
guard_span = s. span ;
2004
- this. lower_let_expr ( block, s, pat, match_scope, None , arm_span )
1987
+ this. lower_let_expr ( block, s, pat, match_scope, None , arm . span )
2005
1988
}
2006
1989
} ) ;
2007
1990
@@ -2317,24 +2300,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2317
2300
let matching = this. bind_pattern (
2318
2301
this. source_info ( pattern. span ) ,
2319
2302
candidate,
2320
- None ,
2321
2303
& fake_borrow_temps,
2322
2304
initializer_span,
2323
2305
None ,
2324
- None ,
2325
- None ,
2326
2306
true ,
2327
2307
) ;
2328
2308
// This block is for the failure case
2329
2309
let failure = this. bind_pattern (
2330
2310
this. source_info ( else_block_span) ,
2331
2311
wildcard,
2332
- None ,
2333
2312
& fake_borrow_temps,
2334
2313
initializer_span,
2335
2314
None ,
2336
- None ,
2337
- None ,
2338
2315
true ,
2339
2316
) ;
2340
2317
this. break_for_else ( failure, * let_else_scope, this. source_info ( initializer_span) ) ;
0 commit comments