Rollup merge of #109680 - clubby789:array-subslice-2229, r=davidtwco
Fix subslice capture in closure Fixes #109298 by refining captures in the same way for Subslices and Indexes. The comment `// we never capture this` seems to have been inaccurate, as changing it to an assert causes many test failures `@rustbot` label +A-closures
This commit is contained in:
commit
45fcb6fd7c
3 changed files with 41 additions and 3 deletions
|
@ -1893,14 +1893,13 @@ fn restrict_capture_precision(
|
|||
|
||||
for (i, proj) in place.projections.iter().enumerate() {
|
||||
match proj.kind {
|
||||
ProjectionKind::Index => {
|
||||
// Arrays are completely captured, so we drop Index projections
|
||||
ProjectionKind::Index | ProjectionKind::Subslice => {
|
||||
// Arrays are completely captured, so we drop Index and Subslice projections
|
||||
truncate_place_to_len_and_update_capture_kind(&mut place, &mut curr_mode, i);
|
||||
return (place, curr_mode);
|
||||
}
|
||||
ProjectionKind::Deref => {}
|
||||
ProjectionKind::Field(..) => {} // ignore
|
||||
ProjectionKind::Subslice => {} // We never capture this
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue