-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)AsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.Category: This is a bug.T-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
Unused arguments to async fn
are not moved into the resulting generator so are dropped before the future runs, here's some example psuedo-code demonstrating this (full running playground example here):
async fn foo(log1: DropLog, _log2: DropLog) {
println!("Got log1: {:?}", log1);
}
fn bar(log1: DropLog, _log2: DropLog) {
println!("Got log1: {:?}", log1);
}
fn main() {
foo(DropLog(1), DropLog(2)).poll(...);
println!();
bar(DropLog(3), DropLog(4));
}
which gives the output:
Dropped DropLog(2)
Got log1: DropLog(1)
Dropped DropLog(1)
Got log1: DropLog(3)
Dropped DropLog(4)
Dropped DropLog(3)
I found this because of a related issue with futures-await(0.1)
posted to urlo, it's at the very least surprising behaviour that needs documenting if not a bug.
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-destructorsArea: Destructors (`Drop`, …)Area: Destructors (`Drop`, …)AsyncAwait-PolishAsync-await issues that are part of the "polish" areaAsync-await issues that are part of the "polish" areaC-bugCategory: This is a bug.Category: This is a bug.T-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