mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-28 15:43:21 +00:00
Use iter::position in truncate_capture_for_move
This commit is contained in:
parent
1b86ad8485
commit
f99e152e5a
@ -1461,16 +1461,10 @@ fn restrict_capture_precision<'tcx>(mut place: Place<'tcx>) -> Place<'tcx> {
|
||||
|
||||
/// Truncates a place so that the resultant capture doesn't move data out of a reference
|
||||
fn truncate_capture_for_move(mut place: Place<'tcx>) -> Place<'tcx> {
|
||||
for (i, proj) in place.projections.iter().enumerate() {
|
||||
match proj.kind {
|
||||
ProjectionKind::Deref => {
|
||||
// We only drop Derefs in case of move closures
|
||||
// There might be an index projection or raw ptr ahead, so we don't stop here.
|
||||
place.projections.truncate(i);
|
||||
return place;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if let Some(i) = place.projections.iter().position(|proj| proj.kind == ProjectionKind::Deref) {
|
||||
// We only drop Derefs in case of move closures
|
||||
// There might be an index projection or raw ptr ahead, so we don't stop here.
|
||||
place.projections.truncate(i);
|
||||
}
|
||||
|
||||
place
|
||||
|
Loading…
Reference in New Issue
Block a user