Inconsistency in Send/Sync requirements for async/await #59245
Closed
Description
opened on Mar 16, 2019
The following code, when switching between lines 14 and 15 (the two versions of the for
line), oscillates between compiling and not compiling because it requires Sync
for the dyn Send
items:
#![feature(async_await, await_macro, futures_api)]
use std::collections::VecDeque;
use std::future::Future;
pub async fn receive<HandleFn, Fut, Ret>(handle: HandleFn) -> Ret
where
Fut: Future<Output = ()>,
HandleFn: Fn() -> Fut,
{
let v: VecDeque<Box<dyn Send>> = VecDeque::new();
let l = v.len();
for _i in 0..v.len() {
//for _i in 0..l {
await!(handle());
}
loop {}
}
fn do_stuff<F: Future + Send>(_f: F) {}
pub fn showcase() {
do_stuff(async {
match await!(receive(async move || ())) {
true => "test",
false => "test",
};
});
}
(Note: this is a simplification of the failure that occurs on Ekleog/erlust@98c6cbc when running cargo test
)
Activity