11 fn require_send(_: impl Send) {}
13 struct Ready<T>(Option<T>);
14 impl<T> Future for Ready<T> {
16 fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
17 Poll::Ready(self.0.take().unwrap())
20 fn ready<T>(t: T) -> Ready<T> {
24 fn make_non_send_future1() -> impl Future<Output = Arc<RefCell<i32>>> {
25 ready(Arc::new(RefCell::new(0)))
29 let send_fut = async {
30 let non_send_fut = make_non_send_future1();
31 let _ = non_send_fut.await;
34 require_send(send_fut);
35 //~^ ERROR future cannot be sent between threads
39 let send_fut = async {
40 let _ = make_non_send_future1().await;
43 require_send(send_fut);
44 //~^ ERROR future cannot be sent between threads
47 async fn ready2<T>(t: T) -> T { t }
48 fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> {
49 ready2(Arc::new(RefCell::new(0)))
52 // Ideally this test would have diagnostics similar to the test above, but right
55 let send_fut = async {
56 let non_send_fut = make_non_send_future2();
57 let _ = non_send_fut.await;
60 require_send(send_fut);
61 //~^ ERROR `RefCell<i32>` cannot be shared between threads safely