2023-10-19 21:46:28 +00:00
|
|
|
#![feature(coroutines)]
|
2023-06-24 10:02:54 +00:00
|
|
|
#![feature(negative_impls)]
|
2017-07-07 23:12:44 +00:00
|
|
|
|
2023-06-24 10:02:54 +00:00
|
|
|
struct NotSend;
|
|
|
|
struct NotSync;
|
|
|
|
|
|
|
|
impl !Send for NotSend {}
|
|
|
|
impl !Sync for NotSync {}
|
2017-07-07 23:12:44 +00:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
fn assert_sync<T: Sync>(_: T) {}
|
|
|
|
fn assert_send<T: Send>(_: T) {}
|
|
|
|
|
|
|
|
assert_sync(|| {
|
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 23:12:44 +00:00
|
|
|
yield;
|
2023-06-24 10:02:54 +00:00
|
|
|
drop(a);
|
2017-07-07 23:12:44 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
assert_send(|| {
|
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 23:12:44 +00:00
|
|
|
yield;
|
2023-06-24 10:02:54 +00:00
|
|
|
drop(a);
|
2017-07-07 23:12:44 +00:00
|
|
|
});
|
|
|
|
}
|