2 // revisions: no_drop_tracking drop_tracking
3 // [drop_tracking] compile-flags: -Zdrop-tracking=yes
4 // [no_drop_tracking] compile-flags: -Zdrop-tracking=no
11 task::{Context, Poll},
14 fn require_send(_: impl Send) {}
16 struct Ready<T>(Option<T>);
17 impl<T> Future for Ready<T> {
19 fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
20 Poll::Ready(self.0.take().unwrap())
23 fn ready<T>(t: T) -> Ready<T> {
27 fn make_non_send_future1() -> impl Future<Output = Arc<RefCell<i32>>> {
28 ready(Arc::new(RefCell::new(0)))
32 let send_fut = async {
33 let non_send_fut = make_non_send_future1();
34 let _ = non_send_fut.await;
37 require_send(send_fut);
38 //~^ ERROR future cannot be sent between threads
42 let send_fut = async {
43 let _ = make_non_send_future1().await;
46 require_send(send_fut);
47 //~^ ERROR future cannot be sent between threads
50 async fn ready2<T>(t: T) -> T {
53 fn make_non_send_future2() -> impl Future<Output = Arc<RefCell<i32>>> {
54 ready2(Arc::new(RefCell::new(0)))
57 // Ideally this test would have diagnostics similar to the test above, but right
60 let send_fut = async {
61 let non_send_fut = make_non_send_future2();
62 let _ = non_send_fut.await;
65 require_send(send_fut);
66 //~^ ERROR `RefCell<i32>` cannot be shared between threads safely