Repository navigation
A closure passed to a call is judged by its capture facts, against the receiver and the caller's live views (#615) - #3451
Merged
Merged
Conversation
added 3 commits
November 18, 2026 18:17
…e receiver and against the caller's live views (#615)
… counts it once zip is instantiated in the compiler)
This was referenced Nov 19, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #615 (D218). It closes a use-after-free in safe code and does not close the issue: the refusal of a read-only capture of a
mutreceiver, and the closure type with amutparameter that its fix-it needs, come with spec words.The hole. A callee holds a view into
self.itemsacross the call of its closure; the closure pushes tox.items; the list reallocates and the view reads freed memory (it printed 0 for an element that was 7). The same through a read-only receiver, a&Tparameter of a free function, and a view the caller holds across a call that takes a writing closure.Two causes.
y.items.push(1)). Both now read the capture summary the body's own check computed (D65). The method-call path passes the receiver, which it never did.check_mutation_against_viewsremoved a borrow it judged dead while checking a closure body, where a view of the enclosing function has no later use. Those borrows now survive the body (closure_body_borrow_floor), and the closure's writes are judged where it is passed (check_capture_write_against_views).Still accepted: a closure that only reads the place another argument borrows; one that writes a field while a view of a sibling field is live; one that writes a place nothing else holds.
Also: the error cites §3.2 (it said §15.7);
WITH_DEBUG_BORROWStraces the closure's captures;tools/verdict.wreads the battery's stage reds (RED (census): …printed green);Zipped.nextdrops a redundantSomethe census counted once the compiler usedzip.Allowance:
index-loopin src 1561 → 1562: the new check walks the borrow table, parallel lists read by one index.Five tests (four refusals, one for what stays legal). Battery green on the branch tip.