]> git.proxmox.com Git - rustc.git/blob - tests/ui/generator/partial-drop.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / tests / ui / generator / partial-drop.rs
1 // check-pass
2 #![feature(negative_impls, generators)]
3
4 struct Foo;
5 impl !Send for Foo {}
6
7 struct Bar {
8 foo: Foo,
9 x: i32,
10 }
11
12 fn main() {
13 assert_send(|| {
14 let guard = Bar { foo: Foo, x: 42 };
15 drop(guard.foo);
16 yield;
17 });
18
19 assert_send(|| {
20 let mut guard = Bar { foo: Foo, x: 42 };
21 drop(guard);
22 guard = Bar { foo: Foo, x: 23 };
23 yield;
24 });
25
26 assert_send(|| {
27 let guard = Bar { foo: Foo, x: 42 };
28 let Bar { foo, x } = guard;
29 drop(foo);
30 yield;
31 });
32 }
33
34 fn assert_send<T: Send>(_: T) {}