-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Implement syntax for anonymous unboxed closures #14449
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
1.0 backcompat lang, but please get an RFC approved. |
This is nearly done. Once |
Tracking rust-lang/rfcs#114 |
This patch primarily does two things: (1) it prevents lifetimes from leaking out of unboxed closures; (2) it allows unboxed closure type notation, call notation, and construction notation to construct closures matching any of the three traits. This breaks code that looked like: let mut f; { let x = &5i; f = |&mut:| *x + 10; } Change this code to avoid having a reference escape. For example: { let x = &5i; let mut f; // <-- move here to avoid dangling reference f = |&mut:| *x + 10; } I believe this is enough to consider unboxed closures essentially implemented. Further issues (for example, higher-rank lifetimes) should be filed as followups. Closes rust-lang#14449. [breaking-change]
…=pnkfelix This patch primarily does two things: (1) it prevents lifetimes from leaking out of unboxed closures; (2) it allows unboxed closure type notation, call notation, and construction notation to construct closures matching any of the three traits. This breaks code that looked like: let mut f; { let x = &5i; f = |&mut:| *x + 10; } Change this code to avoid having a reference escape. For example: { let x = &5i; let mut f; // <-- move here to avoid dangling reference f = |&mut:| *x + 10; } I believe this is enough to consider unboxed closures essentially implemented. Further issues (for example, higher-rank lifetimes) should be filed as followups. Closes #14449. [breaking-change] r? @pnkfelix
Does this mean unboxed closures are done? Because the guide still has procs. The guide could also explain |
@alexchandel unboxed closures have a lot of bugs, and, as with everything Rust-y, migration is not done instantly, it takes time and energy. (The docs/guide are dependent on the stdlib being switched.) |
Also, given that the strategy for this has changed, and the |
Also unifying the syntax in the RFCs might be a really good idea soon. |
fix: Recover from `pub()` visibility modifier
This is part of unboxed closures. cc @nikomatsakis
I suggest that we adopt the following syntax for now. We can change it and bikeshed it later.
These create anonymous struct types that move their upvars (cf. #12831) and implement the
Fn
/FnMut
/FnOnce
traits.Per discussion last week I believe that this is necessary for 1.0. Nominating for backcompat-lang because we will remove the old closures after this is done.
The text was updated successfully, but these errors were encountered: