Hi,
In this playground, I've reproduced the issue in its entirety, but let me summarize it here.
Basically, Rust sensibly allows us to ensure that all variables in the local context are Send when encountering an .await
--- after all, we may be scheduled back onto a different thread! However, the calculation misses a fairly obvious circumstance: what if we manually drop all the non-Send
objects first? For example, where ns
is a non-Send object:
async fn driver() {
let ns = factory();
// invoke something on it that we want to use later that returns a Copy so we can drop ns
let v : usize = ns.dummy();
drop(ns);
// compiler complains that ns may be used across this await, but it's been dropped!
print_value(v).await;
}
If this is wrapped in braces to make the dropping unambiguous, it works as expected. However, that makes passing data around a little more awkward.
Are there any plans to deal with this edge-case? Is this a known issue?