@@ -93,7 +93,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
93
93
let scrutinee_place =
94
94
unpack ! ( block = self . lower_scrutinee( block, scrutinee, scrutinee_span, ) ) ;
95
95
96
- let mut arm_candidates = self . create_match_candidates ( & scrutinee_place, & arms) ;
96
+ let mut arm_candidates = self . create_match_candidates ( scrutinee_place, & arms) ;
97
97
98
98
let match_has_guard = arms. iter ( ) . any ( |arm| arm. guard . is_some ( ) ) ;
99
99
let mut candidates =
@@ -103,7 +103,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
103
103
self . lower_match_tree ( block, scrutinee_span, match_has_guard, & mut candidates) ;
104
104
105
105
self . lower_match_arms (
106
- & destination,
106
+ destination,
107
107
scrutinee_place,
108
108
scrutinee_span,
109
109
arm_candidates,
@@ -137,23 +137,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
137
137
// check safety.
138
138
let cause_matched_place = FakeReadCause :: ForMatchedPlace ;
139
139
let source_info = self . source_info ( scrutinee_span) ;
140
- self . cfg . push_fake_read ( block, source_info, cause_matched_place, scrutinee_place. clone ( ) ) ;
140
+ self . cfg . push_fake_read ( block, source_info, cause_matched_place, scrutinee_place) ;
141
141
142
142
block. and ( scrutinee_place)
143
143
}
144
144
145
145
/// Create the initial `Candidate`s for a `match` expression.
146
146
fn create_match_candidates < ' pat > (
147
147
& mut self ,
148
- scrutinee : & Place < ' tcx > ,
148
+ scrutinee : Place < ' tcx > ,
149
149
arms : & ' pat [ Arm < ' tcx > ] ,
150
150
) -> Vec < ( & ' pat Arm < ' tcx > , Candidate < ' pat , ' tcx > ) > {
151
151
// Assemble a list of candidates: there is one candidate per pattern,
152
152
// which means there may be more than one candidate *per arm*.
153
153
arms. iter ( )
154
154
. map ( |arm| {
155
155
let arm_has_guard = arm. guard . is_some ( ) ;
156
- let arm_candidate = Candidate :: new ( * scrutinee, & arm. pattern , arm_has_guard) ;
156
+ let arm_candidate = Candidate :: new ( scrutinee, & arm. pattern , arm_has_guard) ;
157
157
( arm, arm_candidate)
158
158
} )
159
159
. collect ( )
@@ -391,7 +391,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
391
391
// Inject a fake read, see comments on `FakeReadCause::ForLet`.
392
392
let pattern_source_info = self . source_info ( irrefutable_pat. span ) ;
393
393
let cause_let = FakeReadCause :: ForLet ;
394
- self . cfg . push_fake_read ( block, pattern_source_info, cause_let, place. clone ( ) ) ;
394
+ self . cfg . push_fake_read ( block, pattern_source_info, cause_let, place) ;
395
395
396
396
let ty_source_info = self . source_info ( user_ty_span) ;
397
397
let user_ty = pat_ascription_ty. user_ty (
@@ -430,7 +430,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
430
430
431
431
_ => {
432
432
let place = unpack ! ( block = self . as_place( block, initializer) ) ;
433
- self . place_into_pattern ( block, irrefutable_pat, & place, true )
433
+ self . place_into_pattern ( block, irrefutable_pat, place, true )
434
434
}
435
435
}
436
436
}
@@ -439,10 +439,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
439
439
& mut self ,
440
440
block : BasicBlock ,
441
441
irrefutable_pat : Pat < ' tcx > ,
442
- initializer : & Place < ' tcx > ,
442
+ initializer : Place < ' tcx > ,
443
443
set_match_place : bool ,
444
444
) -> BlockAnd < ( ) > {
445
- let mut candidate = Candidate :: new ( * initializer, & irrefutable_pat, false ) ;
445
+ let mut candidate = Candidate :: new ( initializer, & irrefutable_pat, false ) ;
446
446
447
447
let fake_borrow_temps =
448
448
self . lower_match_tree ( block, irrefutable_pat. span , false , & mut [ & mut candidate] ) ;
@@ -461,7 +461,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
461
461
VarBindingForm { opt_match_place : Some ( ( ref mut match_place, _) ) , .. } ,
462
462
) ) ) = self . local_decls [ local] . local_info
463
463
{
464
- * match_place = Some ( * initializer) ;
464
+ * match_place = Some ( initializer) ;
465
465
} else {
466
466
bug ! ( "Let binding to non-user variable." )
467
467
}
@@ -897,7 +897,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
897
897
span : Span ,
898
898
start_block : BasicBlock ,
899
899
otherwise_block : & mut Option < BasicBlock > ,
900
- candidates : & mut [ & mut Candidate < _ , ' tcx > ] ,
900
+ candidates : & mut [ & mut Candidate < ' _ , ' tcx > ] ,
901
901
fake_borrows : & mut Option < FxHashSet < Place < ' tcx > > > ,
902
902
) {
903
903
// The candidates are sorted by priority. Check to see whether the
@@ -1121,7 +1121,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1121
1121
for match_pair in match_pairs {
1122
1122
if let PatKind :: Or { ref pats } = * match_pair. pattern . kind {
1123
1123
let or_span = match_pair. pattern . span ;
1124
- let place = & match_pair. place ;
1124
+ let place = match_pair. place ;
1125
1125
1126
1126
first_candidate. visit_leaves ( |leaf_candidate| {
1127
1127
self . test_or_pattern (
@@ -1155,14 +1155,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1155
1155
otherwise : & mut Option < BasicBlock > ,
1156
1156
pats : & ' pat [ Pat < ' tcx > ] ,
1157
1157
or_span : Span ,
1158
- place : & Place < ' tcx > ,
1158
+ place : Place < ' tcx > ,
1159
1159
fake_borrows : & mut Option < FxHashSet < Place < ' tcx > > > ,
1160
1160
) {
1161
1161
debug ! ( "test_or_pattern:\n candidate={:#?}\n pats={:#?}" , candidate, pats) ;
1162
- let mut or_candidates: Vec < _ > = pats
1163
- . iter ( )
1164
- . map ( |pat| Candidate :: new ( place. clone ( ) , pat, candidate. has_guard ) )
1165
- . collect ( ) ;
1162
+ let mut or_candidates: Vec < _ > =
1163
+ pats. iter ( ) . map ( |pat| Candidate :: new ( place, pat, candidate. has_guard ) ) . collect ( ) ;
1166
1164
let mut or_candidate_refs: Vec < _ > = or_candidates. iter_mut ( ) . collect ( ) ;
1167
1165
let otherwise = if candidate. otherwise_block . is_some ( ) {
1168
1166
& mut candidate. otherwise_block
@@ -1368,7 +1366,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1368
1366
}
1369
1367
1370
1368
// Insert a Shallow borrow of any places that is switched on.
1371
- fake_borrows. as_mut ( ) . map ( |fb| fb. insert ( match_place. clone ( ) ) ) ;
1369
+ fake_borrows. as_mut ( ) . map ( |fb| fb. insert ( match_place) ) ;
1372
1370
1373
1371
// perform the test, branching to one of N blocks. For each of
1374
1372
// those N possible outcomes, create a (initially empty)
@@ -1448,7 +1446,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1448
1446
target_blocks
1449
1447
} ;
1450
1448
1451
- self . perform_test ( block, & match_place, & test, make_target_blocks) ;
1449
+ self . perform_test ( block, match_place, & test, make_target_blocks) ;
1452
1450
}
1453
1451
1454
1452
/// Determine the fake borrows that are needed from a set of places that
@@ -1669,9 +1667,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1669
1667
1670
1668
let re_erased = tcx. lifetimes . re_erased ;
1671
1669
let scrutinee_source_info = self . source_info ( scrutinee_span) ;
1672
- for ( place, temp) in fake_borrows {
1673
- let borrow = Rvalue :: Ref ( re_erased, BorrowKind :: Shallow , * place) ;
1674
- self . cfg . push_assign ( block, scrutinee_source_info, & Place :: from ( * temp) , borrow) ;
1670
+ for & ( place, temp) in fake_borrows {
1671
+ let borrow = Rvalue :: Ref ( re_erased, BorrowKind :: Shallow , place) ;
1672
+ self . cfg . push_assign ( block, scrutinee_source_info, & Place :: from ( temp) , borrow) ;
1675
1673
}
1676
1674
1677
1675
// the block to branch to if the guard fails; if there is no
0 commit comments