-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Last uses aren't moved into closures by default #1894
Comments
It occurs to me that the last use analysis might be doing the right thing (I don't know), but the trans code certainly is not. Right now, trans::closure decides whether to copy or move based purely on the capture clause. It shouldn't be a big deal to modify it to consult the last use table, but I'm not sure where to look (e.g., would the last use of the variable be the fn expr itself in this case?) |
@marijnh, you'd know best (see previous comment) |
I initially punted on this because the act of closing over a variable doesn't have a node id associated with it the way regular mentions of a variable have. I agree it should be implemented. Assigning to myself. |
This fails:
Rewriting it with a capture clause works:
This is a bit surprising and makes spawn not do the expected thing when written with the convenient block closure syntax. For this reason core::task uses
fn~
closures with explicit capture clauses.The text was updated successfully, but these errors were encountered: