]> git.lizzy.rs Git - rust.git/blob - tests/ui/generator/not-send-sync.rs
Rollup merge of #107022 - scottmcm:ordering-option-eq, r=m-ou-se
[rust.git] / tests / ui / generator / not-send-sync.rs
1 // revisions: no_drop_tracking drop_tracking drop_tracking_mir
2 // [drop_tracking] compile-flags: -Zdrop-tracking
3 // [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir
4 #![feature(generators)]
5 #![feature(negative_impls)]
6
7 struct NotSend;
8 struct NotSync;
9
10 impl !Send for NotSend {}
11 impl !Sync for NotSync {}
12
13 fn main() {
14     fn assert_sync<T: Sync>(_: T) {}
15     fn assert_send<T: Send>(_: T) {}
16
17     assert_sync(|| {
18         //~^ ERROR: generator cannot be shared between threads safely
19         let a = NotSync;
20         yield;
21         drop(a);
22     });
23
24     assert_send(|| {
25         //~^ ERROR: generator cannot be sent between threads safely
26         let a = NotSend;
27         yield;
28         drop(a);
29     });
30 }