@@ -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
@@ -380,30 +387,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
380
387
///
381
388
/// Modifies `candidates` to store the bindings and type ascriptions for
382
389
/// that candidate.
383
- ///
384
- /// Returns the places that need fake borrows because we bind or test them.
385
390
fn lower_match_tree < ' pat > (
386
391
& mut self ,
387
392
block : BasicBlock ,
388
393
scrutinee_span : Span ,
389
394
scrutinee_place_builder : & PlaceBuilder < ' tcx > ,
390
395
match_start_span : Span ,
391
- match_has_guard : bool ,
392
396
candidates : & mut [ & mut Candidate < ' pat , ' tcx > ] ,
393
- ) -> Vec < ( Place < ' tcx > , Local , FakeBorrowKind ) > {
394
- // The set of places that we are creating fake borrows of. If there are no match guards then
395
- // we don't need any fake borrows, so don't track them.
396
- let fake_borrows: Vec < ( Place < ' tcx > , Local , FakeBorrowKind ) > = if match_has_guard {
397
- util:: collect_fake_borrows (
398
- self ,
399
- candidates,
400
- scrutinee_span,
401
- scrutinee_place_builder. base ( ) ,
402
- )
403
- } else {
404
- Vec :: new ( )
405
- } ;
406
-
397
+ ) {
407
398
// See the doc comment on `match_candidates` for why we have an
408
399
// otherwise block. Match checking will ensure this is actually
409
400
// unreachable.
@@ -455,8 +446,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
455
446
previous_candidate = Some ( leaf_candidate) ;
456
447
} ) ;
457
448
}
458
-
459
- fake_borrows
460
449
}
461
450
462
451
/// Lower the bindings, guards and arm bodies of a `match` expression.
@@ -764,18 +753,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
764
753
}
765
754
}
766
755
767
- let fake_borrow_temps = self . lower_match_tree (
756
+ self . lower_match_tree (
768
757
block,
769
758
irrefutable_pat. span ,
770
759
& initializer,
771
760
irrefutable_pat. span ,
772
- false ,
773
761
& mut [ & mut candidate] ,
774
762
) ;
775
763
self . bind_pattern (
776
764
self . source_info ( irrefutable_pat. span ) ,
777
765
candidate,
778
- fake_borrow_temps . as_slice ( ) ,
766
+ & [ ] ,
779
767
irrefutable_pat. span ,
780
768
None ,
781
769
false ,
@@ -2009,12 +1997,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2009
1997
let mut guard_candidate = Candidate :: new ( expr_place_builder. clone ( ) , pat, false , self ) ;
2010
1998
let mut otherwise_candidate =
2011
1999
Candidate :: new ( expr_place_builder. clone ( ) , & wildcard, false , self ) ;
2012
- let fake_borrow_temps = self . lower_match_tree (
2000
+ self . lower_match_tree (
2013
2001
block,
2014
2002
pat. span ,
2015
2003
& expr_place_builder,
2016
2004
pat. span ,
2017
- false ,
2018
2005
& mut [ & mut guard_candidate, & mut otherwise_candidate] ,
2019
2006
) ;
2020
2007
let expr_place = expr_place_builder. try_to_place ( self ) ;
@@ -2029,7 +2016,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2029
2016
let post_guard_block = self . bind_pattern (
2030
2017
self . source_info ( pat. span ) ,
2031
2018
guard_candidate,
2032
- fake_borrow_temps . as_slice ( ) ,
2019
+ & [ ] ,
2033
2020
expr_span,
2034
2021
None ,
2035
2022
false ,
@@ -2504,19 +2491,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2504
2491
let pat = Pat { ty : pattern. ty , span : else_block_span, kind : PatKind :: Wild } ;
2505
2492
let mut wildcard = Candidate :: new ( scrutinee. clone ( ) , & pat, false , this) ;
2506
2493
let mut candidate = Candidate :: new ( scrutinee. clone ( ) , pattern, false , this) ;
2507
- let fake_borrow_temps = this. lower_match_tree (
2494
+ this. lower_match_tree (
2508
2495
block,
2509
2496
initializer_span,
2510
2497
& scrutinee,
2511
2498
pattern. span ,
2512
- false ,
2513
2499
& mut [ & mut candidate, & mut wildcard] ,
2514
2500
) ;
2515
2501
// This block is for the matching case
2516
2502
let matching = this. bind_pattern (
2517
2503
this. source_info ( pattern. span ) ,
2518
2504
candidate,
2519
- fake_borrow_temps . as_slice ( ) ,
2505
+ & [ ] ,
2520
2506
initializer_span,
2521
2507
None ,
2522
2508
true ,
@@ -2525,7 +2511,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
2525
2511
let failure = this. bind_pattern (
2526
2512
this. source_info ( else_block_span) ,
2527
2513
wildcard,
2528
- fake_borrow_temps . as_slice ( ) ,
2514
+ & [ ] ,
2529
2515
initializer_span,
2530
2516
None ,
2531
2517
true ,
0 commit comments