2024-04-11 13:15:34 +00:00
|
|
|
#![feature(coroutines, stmt_expr_attributes)]
|
2023-06-24 10:02:54 +00:00
|
|
|
#![feature(negative_impls)]
|
2017-07-07 16:12:44 -07:00
|
|
|
|
2023-06-24 10:02:54 +00:00
|
|
|
struct NotSend;
|
|
|
|
struct NotSync;
|
|
|
|
|
|
|
|
impl !Send for NotSend {}
|
|
|
|
impl !Sync for NotSync {}
|
2017-07-07 16:12:44 -07:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
fn assert_sync<T: Sync>(_: T) {}
|
|
|
|
fn assert_send<T: Send>(_: T) {}
|
|
|
|
|
2024-04-11 13:15:34 +00:00
|
|
|
assert_sync(#[coroutine] || {
|
2023-10-19 21:46:28 +00:00
|
|
|
//~^ ERROR: coroutine cannot be shared between threads safely
|
2023-06-24 10:02:54 +00:00
|
|
|
let a = NotSync;
|
2017-07-07 16:12:44 -07:00
|
|
|
yield;
|
2023-06-24 10:02:54 +00:00
|
|
|
drop(a);
|
2017-07-07 16:12:44 -07:00
|
|
|
});
|
|
|
|
|
2024-04-11 13:15:34 +00:00
|
|
|
assert_send(#[coroutine] || {
|
2023-10-19 21:46:28 +00:00
|
|
|
//~^ ERROR: coroutine cannot be sent between threads safely
|
2023-06-24 10:02:54 +00:00
|
|
|
let a = NotSend;
|
2017-07-07 16:12:44 -07:00
|
|
|
yield;
|
2023-06-24 10:02:54 +00:00
|
|
|
drop(a);
|
2017-07-07 16:12:44 -07:00
|
|
|
});
|
|
|
|
}
|