]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/partial-drop.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / generator / partial-drop.rs
1 // compile-flags: -Zdrop-tracking
2
3 #![feature(negative_impls, generators)]
4
5 struct Foo;
6 impl !Send for Foo {}
7
8 struct Bar {
9     foo: Foo,
10     x: i32,
11 }
12
13 fn main() {
14     assert_send(|| {
15         //~^ ERROR generator cannot be sent between threads safely
16         // FIXME: it would be nice to make this work.
17         let guard = Bar { foo: Foo, x: 42 };
18         drop(guard.foo);
19         yield;
20     });
21
22     assert_send(|| {
23         //~^ ERROR generator cannot be sent between threads safely
24         // FIXME: it would be nice to make this work.
25         let guard = Bar { foo: Foo, x: 42 };
26         drop(guard);
27         guard.foo = Foo;
28         guard.x = 23;
29         yield;
30     });
31
32     assert_send(|| {
33         //~^ ERROR generator cannot be sent between threads safely
34         // FIXME: it would be nice to make this work.
35         let guard = Bar { foo: Foo, x: 42 };
36         let Bar { foo, x } = guard;
37         drop(foo);
38         yield;
39     });
40 }
41
42 fn assert_send<T: Send>(_: T) {}