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

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

22 lines
395 B
Rust
Raw Normal View History

2017-07-20 06:07:58 +00:00
#![feature(generators)]
2017-07-07 23:12:44 +00:00
2023-05-07 18:38:52 +00:00
use std::cell::Cell;
2017-07-07 23:12:44 +00:00
fn main() {
fn assert_sync<T: Sync>(_: T) {}
fn assert_send<T: Send>(_: T) {}
assert_sync(|| {
//~^ ERROR: generator cannot be shared between threads safely
2023-05-07 18:38:52 +00:00
let a = Cell::new(2);
2017-07-07 23:12:44 +00:00
yield;
});
2023-05-07 18:38:52 +00:00
let a = Cell::new(2);
2017-07-07 23:12:44 +00:00
assert_send(|| {
2023-05-07 18:38:52 +00:00
//~^ ERROR: E0277
drop(&a);
2017-07-07 23:12:44 +00:00
yield;
});
}