Skip to content

Reject a closure move while a reference to that binding is still in scope. - #33

Merged
Cod-e-Codes merged 1 commit into
mainfrom
closure-unused-borrow
Sep 24, 2026
Merged

Cod-e-Codes merged 1 commit into
mainfrom
closure-unused-borrow

Conversation

@Cod-e-Codes

Copy link
Copy Markdown
Owner

Summary

  • A move of a non-Copy binding into a closure is BorrowConflict while a & or &mut of that binding is still in scope, including a reference that is never read.
  • A use of the owner after that reference's last use, outside a closure, is unchanged. This is not an ABI change.

Test plan

  • test_closure_unused_borrow_error.ion expects BorrowConflict
  • test_unwrap_after_borrow.ion exits 1
  • test_closure_copy_after_borrow.ion exits 10
  • cargo test --lib, cargo clippy -- -D warnings, and test_runner.sh (544 passed)

…cope.

An unused borrow ended at its let, so moving the owner into a closure compiled and left the pointer in the local. That move is now BorrowConflict. A use after the reference's last use, outside a closure, is unchanged.
@Cod-e-Codes
Cod-e-Codes merged commit 8a5557b into main Sep 24, 2026
8 checks passed
@Cod-e-Codes
Cod-e-Codes deleted the closure-unused-borrow branch September 24, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant