diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:13 +0000 |
commit | 218caa410aa38c29984be31a5229b9fa717560ee (patch) | |
tree | c54bd55eeb6e4c508940a30e94c0032fbd45d677 /src/test/ui/async-await/async-fn-nonsend.rs | |
parent | Releasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/test/ui/async-await/async-fn-nonsend.rs')
-rw-r--r-- | src/test/ui/async-await/async-fn-nonsend.rs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/test/ui/async-await/async-fn-nonsend.rs b/src/test/ui/async-await/async-fn-nonsend.rs deleted file mode 100644 index d7f8d7ac5..000000000 --- a/src/test/ui/async-await/async-fn-nonsend.rs +++ /dev/null @@ -1,74 +0,0 @@ -// edition:2018 -// compile-flags: --crate-type lib -Zdrop-tracking - -use std::{cell::RefCell, fmt::Debug, rc::Rc}; - -fn non_sync() -> impl Debug { - RefCell::new(()) -} - -fn non_send() -> impl Debug { - Rc::new(()) -} - -fn take_ref<T>(_: &T) {} - -async fn fut() {} - -async fn fut_arg<T>(_: T) {} - -async fn local_dropped_before_await() { - // this is okay now because of the drop - let x = non_send(); - drop(x); - fut().await; -} - -async fn non_send_temporary_in_match() { - // We could theoretically make this work as well (produce a `Send` future) - // for scrutinees / temporaries that can or will - // be dropped prior to the match body - // (e.g. `Copy` types). - match Some(non_send()) { - Some(_) => fut().await, - None => {} - } -} - -fn get_formatter() -> std::fmt::Formatter<'static> { - panic!() -} - -async fn non_sync_with_method_call() { - let f: &mut std::fmt::Formatter = &mut get_formatter(); - // It would by nice for this to work. - if non_sync().fmt(f).unwrap() == () { - fut().await; - } -} - -async fn non_sync_with_method_call_panic() { - let f: &mut std::fmt::Formatter = panic!(); - if non_sync().fmt(f).unwrap() == () { - fut().await; - } -} - -async fn non_sync_with_method_call_infinite_loop() { - let f: &mut std::fmt::Formatter = loop {}; - if non_sync().fmt(f).unwrap() == () { - fut().await; - } -} - -fn assert_send(_: impl Send) {} - -pub fn pass_assert() { - assert_send(local_dropped_before_await()); - assert_send(non_send_temporary_in_match()); - //~^ ERROR future cannot be sent between threads safely - assert_send(non_sync_with_method_call()); - //~^ ERROR future cannot be sent between threads safely - assert_send(non_sync_with_method_call_panic()); - assert_send(non_sync_with_method_call_infinite_loop()); -} |