File tree 1 file changed +4
-10
lines changed
compiler/rustc_typeck/src/check
1 file changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -1461,16 +1461,10 @@ fn restrict_capture_precision<'tcx>(mut place: Place<'tcx>) -> Place<'tcx> {
1461
1461
1462
1462
/// Truncates a place so that the resultant capture doesn't move data out of a reference
1463
1463
fn truncate_capture_for_move ( mut place : Place < ' tcx > ) -> Place < ' tcx > {
1464
- for ( i, proj) in place. projections . iter ( ) . enumerate ( ) {
1465
- match proj. kind {
1466
- ProjectionKind :: Deref => {
1467
- // We only drop Derefs in case of move closures
1468
- // There might be an index projection or raw ptr ahead, so we don't stop here.
1469
- place. projections . truncate ( i) ;
1470
- return place;
1471
- }
1472
- _ => { }
1473
- }
1464
+ if let Some ( i) = place. projections . iter ( ) . position ( |proj| proj. kind == ProjectionKind :: Deref ) {
1465
+ // We only drop Derefs in case of move closures
1466
+ // There might be an index projection or raw ptr ahead, so we don't stop here.
1467
+ place. projections . truncate ( i) ;
1474
1468
}
1475
1469
1476
1470
place
You can’t perform that action at this time.
0 commit comments