2020-09-10 23:41:02 -04:00
|
|
|
// compile-flags: -Zverbose
|
|
|
|
|
|
|
|
// Same as test/ui/generator/not-send-sync.rs
|
|
|
|
#![feature(generators)]
|
|
|
|
|
2023-05-07 18:38:52 +00:00
|
|
|
use std::cell::Cell;
|
2020-09-10 23:41:02 -04: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);
|
2020-09-10 23:41:02 -04:00
|
|
|
yield;
|
|
|
|
});
|
|
|
|
|
2023-05-07 18:38:52 +00:00
|
|
|
let a = Cell::new(2);
|
2020-09-10 23:41:02 -04:00
|
|
|
assert_send(|| {
|
2023-05-07 18:38:52 +00:00
|
|
|
//~^ ERROR: E0277
|
|
|
|
drop(&a);
|
2020-09-10 23:41:02 -04:00
|
|
|
yield;
|
|
|
|
});
|
|
|
|
}
|