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