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