This is a tracking issue for the RFC "Closures Capture Disjoint Fields" (rust-lang/rfcs#2229).
This is under active development by the wg-rfc-2229 compiler-team working group. You can follow along in #t-compiler/wg-rfc-2229 stream of the rust-lang Zulip.
freevars, which are tied to the variables, and instead to use a map produced by the type-checkerupvars query to upvars_mentioned https://github.com/rust-lang/rust/pull/72544upvars_list to closure_captures https://github.com/rust-lang/rust/pull/72591upvars_mentioned query to extract information from the typeck tables (https://github.com/sexxi-goose/rust/issues/4)hir::Place to include full detail on projectionshir::Place to separate out the hir_id and Span (that is a PlaceReference) hir::Place instead of just an upvarhir::Place capturesAt this point, the implementation will capture paths and not just variables, but this will be a breaking change. Remaining work would be to:
Unresolved questions:
repr, refinement typing)?Box be special?
This issue has been assigned to @arora-aman via this comment.
IIRC, this needs to wait for the new MIR (NLL) borrow-checker to replace the old one.
cc @rust-lang/wg-compiler-nll
I would love to follow this through and give the code a shot, but it's probably too big of a first contribution to the compiler. Maybe I'll take a swing at some starter issues and then come back if no one else has gotten it done.
@eddyb Yes, this definitely should be built on NLL.
@blitzerr could you please provide a status update on this? it looks like the related issues (#57482 and #60205) had some work done, but they look stuck now. Anything that needs help with? Not sure if I can do anything, but I can try :)
Concern: How does this feature interact with self-referential struct?
@lzutao Rust has no native support for self referential types, so you will just have to be careful with the unsafe code you write.
I know. But with polonius, there might be support for self-referential types in the future. So for future design space we need to care about how to interact this feature with self-referential types.
This is the first I've heard of Polonius having anything to do with self-referential types, despite having read all the blog posts and docs behind your link. Is this interaction spelled out somewhere?
@Ixrec I do recall that there was a presentation from Niko that says it could maybe help with self-referential structs somehow, but he did preface it by saying that it's purely speculative: https://youtu.be/_agDeiWek8w?t=1900.
I'm not really aware of any particular interaction between this feature and self-referential types. Am I missing something?
@rustbot assign arora-aman
Error: Parsing assign command in comment failed: ...'arora-aman' | error: user should start with @ at >| ''...
Please let @rust-lang/release know if you're having trouble with this bot.
@rustbot assign @arora-aman
@rustbot claim
Most helpful comment
I'm not really aware of any particular interaction between this feature and self-referential types. Am I missing something?