@@ -315,12 +315,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
315315
316316 let match_start_span = span. shrink_to_lo ( ) . to ( scrutinee_span) ;
317317
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 (
319327 block,
320328 scrutinee_span,
321329 & scrutinee_place,
322330 match_start_span,
323- match_has_guard,
324331 & mut candidates,
325332 ) ;
326333
@@ -380,30 +387,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
380387 ///
381388 /// Modifies `candidates` to store the bindings and type ascriptions for
382389 /// that candidate.
383- ///
384- /// Returns the places that need fake borrows because we bind or test them.
385390 fn lower_match_tree < ' pat > (
386391 & mut self ,
387392 block : BasicBlock ,
388393 scrutinee_span : Span ,
389394 scrutinee_place_builder : & PlaceBuilder < ' tcx > ,
390395 match_start_span : Span ,
391- match_has_guard : bool ,
392396 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+ ) {
407398 // See the doc comment on `match_candidates` for why we have an
408399 // otherwise block. Match checking will ensure this is actually
409400 // unreachable.
@@ -455,8 +446,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
455446 previous_candidate = Some ( leaf_candidate) ;
456447 } ) ;
457448 }
458-
459- fake_borrows
460449 }
461450
462451 /// Lower the bindings, guards and arm bodies of a `match` expression.
@@ -764,18 +753,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
764753 }
765754 }
766755
767- let fake_borrow_temps = self . lower_match_tree (
756+ self . lower_match_tree (
768757 block,
769758 irrefutable_pat. span ,
770759 & initializer,
771760 irrefutable_pat. span ,
772- false ,
773761 & mut [ & mut candidate] ,
774762 ) ;
775763 self . bind_pattern (
776764 self . source_info ( irrefutable_pat. span ) ,
777765 candidate,
778- fake_borrow_temps . as_slice ( ) ,
766+ & [ ] ,
779767 irrefutable_pat. span ,
780768 None ,
781769 false ,
@@ -2009,12 +1997,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20091997 let mut guard_candidate = Candidate :: new ( expr_place_builder. clone ( ) , pat, false , self ) ;
20101998 let mut otherwise_candidate =
20111999 Candidate :: new ( expr_place_builder. clone ( ) , & wildcard, false , self ) ;
2012- let fake_borrow_temps = self . lower_match_tree (
2000+ self . lower_match_tree (
20132001 block,
20142002 pat. span ,
20152003 & expr_place_builder,
20162004 pat. span ,
2017- false ,
20182005 & mut [ & mut guard_candidate, & mut otherwise_candidate] ,
20192006 ) ;
20202007 let expr_place = expr_place_builder. try_to_place ( self ) ;
@@ -2029,7 +2016,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
20292016 let post_guard_block = self . bind_pattern (
20302017 self . source_info ( pat. span ) ,
20312018 guard_candidate,
2032- fake_borrow_temps . as_slice ( ) ,
2019+ & [ ] ,
20332020 expr_span,
20342021 None ,
20352022 false ,
@@ -2504,19 +2491,18 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
25042491 let pat = Pat { ty : pattern. ty , span : else_block_span, kind : PatKind :: Wild } ;
25052492 let mut wildcard = Candidate :: new ( scrutinee. clone ( ) , & pat, false , this) ;
25062493 let mut candidate = Candidate :: new ( scrutinee. clone ( ) , pattern, false , this) ;
2507- let fake_borrow_temps = this. lower_match_tree (
2494+ this. lower_match_tree (
25082495 block,
25092496 initializer_span,
25102497 & scrutinee,
25112498 pattern. span ,
2512- false ,
25132499 & mut [ & mut candidate, & mut wildcard] ,
25142500 ) ;
25152501 // This block is for the matching case
25162502 let matching = this. bind_pattern (
25172503 this. source_info ( pattern. span ) ,
25182504 candidate,
2519- fake_borrow_temps . as_slice ( ) ,
2505+ & [ ] ,
25202506 initializer_span,
25212507 None ,
25222508 true ,
@@ -2525,7 +2511,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
25252511 let failure = this. bind_pattern (
25262512 this. source_info ( else_block_span) ,
25272513 wildcard,
2528- fake_borrow_temps . as_slice ( ) ,
2514+ & [ ] ,
25292515 initializer_span,
25302516 None ,
25312517 true ,
0 commit comments