rust/tests/ui/coroutine/not-send-sync.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
539 B
Rust
Raw Normal View History

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
});
}