@@ -97,8 +97,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
97
97
let scrutinee_place =
98
98
unpack ! ( block = self . lower_scrutinee( block, scrutinee, scrutinee_span, ) ) ;
99
99
100
- let mut arm_candidates =
101
- self . create_match_candidates ( scrutinee_place. clone ( ) , & arms. clone ( ) ) ;
100
+ let mut arm_candidates = self . create_match_candidates ( scrutinee_place. clone ( ) , & arms) ;
102
101
103
102
let match_has_guard = arms. iter ( ) . any ( |arm| arm. guard . is_some ( ) ) ;
104
103
let mut candidates =
@@ -244,8 +243,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
244
243
let arm_source_info = self . source_info ( arm. span ) ;
245
244
let arm_scope = ( arm. scope , arm_source_info) ;
246
245
self . in_scope ( arm_scope, arm. lint_level , |this| {
247
- let body = arm. body ;
248
-
249
246
// `try_upvars_resolved` may fail if it is unable to resolve the given
250
247
// `PlaceBuilder` inside a closure. In this case, we don't want to include
251
248
// a scrutinee place. `scrutinee_place_builder` will fail to be resolved
@@ -264,7 +261,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
264
261
. try_upvars_resolved ( this. tcx , this. typeck_results )
265
262
{
266
263
scrutinee_place =
267
- scrutinee_builder. clone ( ) . into_place ( this. tcx , this. typeck_results ) ;
264
+ scrutinee_builder. into_place ( this. tcx , this. typeck_results ) ;
268
265
opt_scrutinee_place = Some ( ( Some ( & scrutinee_place) , scrutinee_span) ) ;
269
266
}
270
267
let scope = this. declare_bindings (
@@ -524,9 +521,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
524
521
if let Ok ( match_pair_resolved) =
525
522
initializer. clone ( ) . try_upvars_resolved ( self . tcx , self . typeck_results )
526
523
{
527
- let place = match_pair_resolved
528
- . clone ( )
529
- . into_place ( self . tcx , self . typeck_results ) ;
524
+ let place =
525
+ match_pair_resolved. into_place ( self . tcx , self . typeck_results ) ;
530
526
* match_place = Some ( place) ;
531
527
}
532
528
} else {
@@ -1480,7 +1476,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1480
1476
}
1481
1477
TestKind :: Switch { adt_def : _, ref mut variants } => {
1482
1478
for candidate in candidates. iter ( ) {
1483
- if !self . add_variants_to_switch ( & match_place. clone ( ) , candidate, variants) {
1479
+ if !self . add_variants_to_switch ( & match_place, candidate, variants) {
1484
1480
break ;
1485
1481
}
1486
1482
}
@@ -1493,8 +1489,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1493
1489
if let Ok ( match_place_resolved) =
1494
1490
match_place. clone ( ) . try_upvars_resolved ( self . tcx , self . typeck_results )
1495
1491
{
1496
- let resolved_place =
1497
- match_place_resolved. clone ( ) . into_place ( self . tcx , self . typeck_results ) ;
1492
+ let resolved_place = match_place_resolved. into_place ( self . tcx , self . typeck_results ) ;
1498
1493
fb. insert ( resolved_place) ;
1499
1494
}
1500
1495
}
@@ -1577,7 +1572,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1577
1572
target_blocks
1578
1573
} ;
1579
1574
1580
- self . perform_test ( block, match_place. clone ( ) , & test, make_target_blocks) ;
1575
+ self . perform_test ( block, match_place, & test, make_target_blocks) ;
1581
1576
}
1582
1577
1583
1578
/// Determine the fake borrows that are needed from a set of places that
@@ -1811,9 +1806,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1811
1806
}
1812
1807
Guard :: IfLet ( pat, scrutinee) => {
1813
1808
let scrutinee_span = scrutinee. span ;
1814
- let scrutinee_place_builder = unpack ! (
1815
- block = self . lower_scrutinee( block, scrutinee. clone( ) , scrutinee_span)
1816
- ) ;
1809
+ let scrutinee_place_builder =
1810
+ unpack ! ( block = self . lower_scrutinee( block, scrutinee, scrutinee_span) ) ;
1817
1811
let mut guard_candidate =
1818
1812
Candidate :: new ( scrutinee_place_builder. clone ( ) , & pat, false ) ;
1819
1813
let wildcard = Pat :: wildcard_from_ty ( pat. ty ) ;
@@ -1827,12 +1821,11 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
1827
1821
) ;
1828
1822
let mut opt_scrutinee_place: Option < ( Option < & Place < ' tcx > > , Span ) > = None ;
1829
1823
let scrutinee_place: Place < ' tcx > ;
1830
- if let Ok ( scrutinee_builder) = scrutinee_place_builder
1831
- . clone ( )
1832
- . try_upvars_resolved ( self . tcx , self . typeck_results )
1824
+ if let Ok ( scrutinee_builder) =
1825
+ scrutinee_place_builder. try_upvars_resolved ( self . tcx , self . typeck_results )
1833
1826
{
1834
1827
scrutinee_place =
1835
- scrutinee_builder. clone ( ) . into_place ( self . tcx , self . typeck_results ) ;
1828
+ scrutinee_builder. into_place ( self . tcx , self . typeck_results ) ;
1836
1829
opt_scrutinee_place = Some ( ( Some ( & scrutinee_place) , scrutinee_span) ) ;
1837
1830
}
1838
1831
self . declare_bindings (
0 commit comments