Closed
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.