/ rust Public
Explain why borrows can't be held across yield point in async blocks/functions #78938
Area: Async & Await
Area: Messages for errors, warnings, and lints
Area: lifetime related
Async-await issues that have been triaged during a working group meeting.
Confusing diagnostic error that should be reworked
Confusing diagnostic error hard to understand for new users
Call for participation: Experience needed to fix: Easy / not much (good first issue)
Call for participation: This issue has a mentor. Use RustcContributor::new on Zulip for discussion.
Relevant to the compiler team, which will review and decide on the PR/issue.
Consider the following code:
The error message has a helpful hint:
But it doesn't explain very well why
In particular, 'async block may outlive the current function' makes no sense without a very good mental model of async: the future is
awaited within the current function, so of course it can't outlive it. The thing to realize here is that even though it's written as one function, it's actually two: one executed before the yield point, and one after, and the stack space for the first function goes away when you call
It would be nice to instead say something like
The text was updated successfully, but these errors were encountered: