-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Closed
Copy link
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
This asynchronous function:
async fn foo_async(x: D, y: D) {
helper_async(&D()).await
// ^^^ temporary D
}
async fn helper_async(v: &D) { }
will drop first y, then x, then the temporary D. However an equivalent synchronous function (playground) would drop the temporary, then y, then x. The problem is our desugaring for async fn, which looks something like this:
// async fn foo_async($parameter_patterns) { $body }
fn foo_async(raw_parameters) {
async move {
let $parameter_patterns = raw-parameters;
$body // body of the async fn
}
}
here, the temporaries in $body
wind up being dropped after the let-bound variables of the block. Proposed fix in a comment below.
sfackler and jebrosen
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitAsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team