2023-12-19 11:39:58 -06:00
|
|
|
//@ compile-flags: -Zverbose-internals
|
2020-09-10 22:41:02 -05:00
|
|
|
|
2023-10-19 16:46:28 -05:00
|
|
|
// Same as test/ui/coroutine/not-send-sync.rs
|
2024-04-11 08:15:34 -05:00
|
|
|
#![feature(coroutines, stmt_expr_attributes)]
|
2023-06-24 05:02:54 -05:00
|
|
|
#![feature(negative_impls)]
|
2020-09-10 22:41:02 -05:00
|
|
|
|
2023-06-24 05:02:54 -05:00
|
|
|
struct NotSend;
|
|
|
|
struct NotSync;
|
|
|
|
|
|
|
|
impl !Send for NotSend {}
|
|
|
|
impl !Sync for NotSync {}
|
2020-09-10 22:41:02 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
fn assert_sync<T: Sync>(_: T) {}
|
|
|
|
fn assert_send<T: Send>(_: T) {}
|
|
|
|
|
2024-04-11 08:15:34 -05:00
|
|
|
assert_sync(#[coroutine] || {
|
2023-10-19 16:46:28 -05:00
|
|
|
//~^ ERROR: coroutine cannot be shared between threads safely
|
2023-06-24 05:02:54 -05:00
|
|
|
let a = NotSync;
|
2020-09-10 22:41:02 -05:00
|
|
|
yield;
|
2023-06-24 05:02:54 -05:00
|
|
|
drop(a);
|
2020-09-10 22:41:02 -05:00
|
|
|
});
|
|
|
|
|
2024-04-11 08:15:34 -05:00
|
|
|
assert_send(#[coroutine] || {
|
2023-10-19 16:46:28 -05:00
|
|
|
//~^ ERROR: coroutine cannot be sent between threads safely
|
2023-06-24 05:02:54 -05:00
|
|
|
let a = NotSend;
|
2020-09-10 22:41:02 -05:00
|
|
|
yield;
|
2023-06-24 05:02:54 -05:00
|
|
|
drop(a);
|
2020-09-10 22:41:02 -05:00
|
|
|
});
|
|
|
|
}
|