-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
async/await borrows more around await points than necessary #61211
Comments
This ... might be a deliberate choice? In particular, there has been some discussion circling around whether the behavior in cases like this should be based on lexical scopes (as I believe is currently the case) or a liveness analysis (which what I think @sdroege is implicitly asking for here)? But I'm not an expert in what is the general expectation when it come to async-await semantics. cc @cramertj and @withoutboats |
Maybe I'm confused, but I don't think this is a deliberate choice and I think its connected #52924. What we've decided is that we don't rearrange destructors in any surprising way, but once something has been dropped we shouldn't need to hold it in the state any longer. I don't think fixing this is a blocker (since it should be strictly backwards compatible for these generators to gain a |
cc @tmandry |
I agree, and it's also easy enough to workaround and you'll notice at compile time. It's mostly an inconvenience. |
Typecheck has its own "view" of what locals might get incorporated into the generator, and that would be what's generating this error. That's separate from the layout code (except that the layout set of saved locals must be a subset of the typecheck set). So I would say this isn't really part of #52924. EDIT: The typeck set is the one in |
This is I think a dup of #57017 |
Based on that, I'm going to mark as deferred -- probably we should move the example into #57017 and close this issue though |
Added it in a comment there. Thanks! |
#57478 is another more specific dup. |
Fails with
When putting the lock into a separate block it works fine, when not awaiting or locking after the last await point it also works fine.
It seems that dropped values at await points are still considered in scope and borrowed.
The text was updated successfully, but these errors were encountered: