2 // compile-flags: --crate-type lib
4 // FIXME(eholk): temporarily disabled while drop range tracking is disabled
5 // (see generator_interior.rs:27)
8 use std::{cell::RefCell, fmt::Debug, rc::Rc};
10 fn non_sync() -> impl Debug {
14 fn non_send() -> impl Debug {
18 fn take_ref<T>(_: &T) {}
22 async fn fut_arg<T>(_: T) {}
24 async fn local_dropped_before_await() {
25 // this is okay now because of the drop
31 async fn non_send_temporary_in_match() {
32 // We could theoretically make this work as well (produce a `Send` future)
33 // for scrutinees / temporaries that can or will
34 // be dropped prior to the match body
35 // (e.g. `Copy` types).
36 match Some(non_send()) {
37 Some(_) => fut().await,
42 fn get_formatter() -> std::fmt::Formatter<'static> {
46 async fn non_sync_with_method_call() {
47 let f: &mut std::fmt::Formatter = &mut get_formatter();
48 // It would by nice for this to work.
49 if non_sync().fmt(f).unwrap() == () {
54 async fn non_sync_with_method_call_panic() {
55 let f: &mut std::fmt::Formatter = panic!();
56 if non_sync().fmt(f).unwrap() == () {
61 async fn non_sync_with_method_call_infinite_loop() {
62 let f: &mut std::fmt::Formatter = loop {};
63 if non_sync().fmt(f).unwrap() == () {
68 fn assert_send(_: impl Send) {}
70 pub fn pass_assert() {
71 assert_send(local_dropped_before_await());
72 assert_send(non_send_temporary_in_match());
73 //~^ ERROR future cannot be sent between threads safely
74 assert_send(non_sync_with_method_call());
75 //~^ ERROR future cannot be sent between threads safely
76 assert_send(non_sync_with_method_call_panic());
77 assert_send(non_sync_with_method_call_infinite_loop());