Don't skip closure captures when fixing them

This commit is contained in:
JRI98 2024-02-03 23:19:08 +00:00
parent 8e3c1597c3
commit be30e470a8
No known key found for this signature in database
GPG key ID: F83B29916FF13F24
3 changed files with 67 additions and 5 deletions

View file

@ -1051,14 +1051,13 @@ fn fix_values_captured_in_closure_expr(
debug_assert!(!captures.is_empty());
captured_symbols.extend(captures);
captured_symbols.swap_remove(i);
// Jump two, because the next element is now one of the newly-added captures,
// which we don't need to check.
i += 2;
added_captures = true;
} else {
i += 1;
}
// Always jump one, because the current element either does not have captures or
// is now one of the newly-added captures, which we don't need to check.
i += 1;
}
if added_captures {
// Re-sort, since we've added new captures.