3 // compile-flags: --crate-type lib
5 use std::{cell::RefCell, fmt::Debug, rc::Rc};
7 fn non_sync() -> impl Debug {
11 fn non_send() -> impl Debug {
15 fn take_ref<T>(_: &T) {}
19 async fn fut_arg<T>(_: T) {}
21 async fn local_dropped_before_await() {
22 // FIXME: it'd be nice for this to be allowed in a `Send` `async fn`
28 async fn non_send_temporary_in_match() {
29 // We could theoretically make this work as well (produce a `Send` future)
30 // for scrutinees / temporaries that can or will
31 // be dropped prior to the match body
32 // (e.g. `Copy` types).
33 match Some(non_send()) {
34 Some(_) => fut().await,
39 async fn non_sync_with_method_call() {
40 // FIXME: it'd be nice for this to work.
41 let f: &mut std::fmt::Formatter = panic!();
42 if non_sync().fmt(f).unwrap() == () {
47 fn assert_send(_: impl Send) {}
49 pub fn pass_assert() {
50 assert_send(local_dropped_before_await());
51 //~^ ERROR future cannot be sent between threads safely
52 assert_send(non_send_temporary_in_match());
53 //~^ ERROR future cannot be sent between threads safely
54 assert_send(non_sync_with_method_call());
55 //~^ ERROR future cannot be sent between threads safely