@@ -315,12 +315,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
315
315
316
316
let match_start_span = span. shrink_to_lo ( ) . to ( scrutinee_span) ;
317
317
318
- let fake_borrow_temps = self . lower_match_tree (
318
+ // The set of places that we are creating fake borrows of. If there are no match guards then
319
+ // we don't need any fake borrows, so don't track them.
320
+ let fake_borrow_temps: Vec < ( Place < ' tcx > , Local , FakeBorrowKind ) > = if match_has_guard {
321
+ util:: collect_fake_borrows ( self , & candidates, scrutinee_span, scrutinee_place. base ( ) )
322
+ } else {
323
+ Vec :: new ( )
324
+ } ;
325
+
326
+ self . lower_match_tree (
319
327
block,
320
328
scrutinee_span,
321
329
& scrutinee_place,
322
330
match_start_span,
323
- match_has_guard,
324
331
& mut candidates,
325
332
) ;
326
333
@@ -377,30 +384,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
377
384
///
378
385
/// Modifies `candidates` to store the bindings and type ascriptions for
379
386
/// that candidate.
380
- ///
381
- /// Returns the places that need fake borrows because we bind or test them.
382
387
fn lower_match_tree < ' pat > (
383
388
& mut self ,
384
389
block : BasicBlock ,
385
390
scrutinee_span : Span ,
386
391
scrutinee_place_builder : & PlaceBuilder < ' tcx > ,
387
392
match_start_span : Span ,
388
- match_has_guard : bool ,
389
393
candidates : & mut [ & mut Candidate < ' pat , ' tcx > ] ,
390
- ) -> Vec < ( Place < ' tcx > , Local , FakeBorrowKind ) > {
391
- // The set of places that we are creating fake borrows of. If there are no match guards then
392
- // we don't need any fake borrows, so don't track them.
393
- let fake_borrows: Vec < ( Place < ' tcx > , Local , FakeBorrowKind ) > = if match_has_guard {
394
- util:: collect_fake_borrows (
395
- self ,
396
- candidates,
397
- scrutinee_span,
398
- scrutinee_place_builder. base ( ) ,
399
- )
400
- } else {
401
- Vec :: new ( )
402
- } ;
403
-
394
+ ) {
404
395
// See the doc comment on `match_candidates` for why we have an
405
396
// otherwise block. Match checking will ensure this is actually
406
397
// unreachable.
@@ -452,8 +443,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
452
443
previous_candidate = Some ( leaf_candidate) ;
453
444
} ) ;
454
445
}
455
-
456
- fake_borrows
457
446
}
458
447
459
448
/// Lower the bindings, guards and arm bodies of a `match` expression.
@@ -761,18 +750,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
761
750
}
762
751
}
763
752
764
- let fake_borrow_temps = self . lower_match_tree (
753
+ self . lower_match_tree (
765
754
block,
766
755
irrefutable_pat. span ,
767
756
& initializer,
768
757
irrefutable_pat. span ,
769
- false ,
770
758
& mut [ & mut candidate] ,
771
759
) ;
772
760
self . bind_pattern (
773
761
self . source_info ( irrefutable_pat. span ) ,
774
762
candidate,
775
- fake_borrow_temps . as_slice ( ) ,
763
+ & [ ] ,
776
764
irrefutable_pat. span ,
777
765
None ,
778
766
false ,
@@ -1995,12 +1983,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1995
1983
let mut guard_candidate = Candidate :: new ( expr_place_builder. clone ( ) , pat, false , self ) ;
1996
1984
let mut otherwise_candidate =
1997
1985
Candidate :: new ( expr_place_builder. clone ( ) , & wildcard, false , self ) ;
1998
- let fake_borrow_temps = self . lower_match_tree (
1986
+ self . lower_match_tree (
1999
1987
block,
2000
1988
pat. span ,
2001
1989
& expr_place_builder,
2002
1990
pat. span ,
2003
- false ,
2004
1991
& mut [ & mut guard_candidate, & mut otherwise_candidate] ,
2005
1992
) ;
2006
1993
let expr_place = expr_place_builder. try_to_place ( self ) ;
@@ -2015,7 +2002,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2015
2002
let post_guard_block = self . bind_pattern (
2016
2003
self . source_info ( pat. span ) ,
2017
2004
guard_candidate,
2018
- fake_borrow_temps . as_slice ( ) ,
2005
+ & [ ] ,
2019
2006
expr_span,
2020
2007
None ,
2021
2008
false ,
@@ -2490,19 +2477,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2490
2477
let pat = Pat { ty : pattern. ty , span : else_block_span, kind : PatKind :: Wild } ;
2491
2478
let mut wildcard = Candidate :: new ( scrutinee. clone ( ) , & pat, false , this) ;
2492
2479
let mut candidate = Candidate :: new ( scrutinee. clone ( ) , pattern, false , this) ;
2493
- let fake_borrow_temps = this. lower_match_tree (
2480
+ this. lower_match_tree (
2494
2481
block,
2495
2482
initializer_span,
2496
2483
& scrutinee,
2497
2484
pattern. span ,
2498
- false ,
2499
2485
& mut [ & mut candidate, & mut wildcard] ,
2500
2486
) ;
2501
2487
// This block is for the matching case
2502
2488
let matching = this. bind_pattern (
2503
2489
this. source_info ( pattern. span ) ,
2504
2490
candidate,
2505
- fake_borrow_temps . as_slice ( ) ,
2491
+ & [ ] ,
2506
2492
initializer_span,
2507
2493
None ,
2508
2494
true ,
@@ -2511,7 +2497,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2511
2497
let failure = this. bind_pattern (
2512
2498
this. source_info ( else_block_span) ,
2513
2499
wildcard,
2514
- fake_borrow_temps . as_slice ( ) ,
2500
+ & [ ] ,
2515
2501
initializer_span,
2516
2502
None ,
2517
2503
true ,
0 commit comments