Skip to content

Commit

Permalink
2229: Handle update to capture kind properly
Browse files Browse the repository at this point in the history
  • Loading branch information
arora-aman committed Aug 29, 2021
1 parent ef52471 commit fbd775f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
};

capture_info.capture_kind = capture_kind;
let capture_info = if let Some(existing) = processed.get(&place) {
determine_capture_info(*existing, capture_info)
} else {
capture_info
};
processed.insert(place, capture_info);
}

Expand Down
19 changes: 19 additions & 0 deletions src/test/ui/closures/2229_closure_analysis/run_pass/issue-88372.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// edition:2021
// run-pass


fn solve<F>(validate: F) -> Option<u64>
where
F: Fn(&mut [i8; 1]),
{
let mut position: [i8; 1] = [1];
Some(0).map(|_| {
validate(&mut position);
let [_x] = position;
0
})
}

fn main() {
solve(|_| ());
}

0 comments on commit fbd775f

Please sign in to comment.