]> git.lizzy.rs Git - rust.git/blob - src/test/ui/generator/issue-57017.rs
Auto merge of #98051 - davidtwco:split-dwarf-stabilization, r=wesleywiser
[rust.git] / src / test / ui / generator / issue-57017.rs
1 // build-pass
2 // compile-flags: -Zdrop-tracking
3 #![feature(generators, negative_impls)]
4
5 macro_rules! type_combinations {
6     (
7         $( $name:ident => { $( $tt:tt )* } );*
8     ) => { $(
9         mod $name {
10             pub mod unsync {
11                 $( $tt )*
12
13                 impl !Sync for Client {}
14             }
15             pub mod unsend {
16                 $( $tt )*
17
18                 impl !Send for Client {}
19             }
20         }
21
22         // This is the same bug as issue 57017, but using yield instead of await
23         {
24             let g = move || match drop(&$name::unsync::Client::default()) {
25                 _status => yield,
26             };
27             assert_send(g);
28         }
29
30         // This tests that `Client` is properly considered to be dropped after moving it into the
31         // function.
32         {
33             let g = move || match drop($name::unsend::Client::default()) {
34                 _status => yield,
35             };
36             assert_send(g);
37         }
38     )* }
39 }
40
41 fn assert_send<T: Send>(_thing: T) {}
42
43 fn main() {
44     type_combinations!(
45         copy => { #[derive(Copy, Clone, Default)] pub struct Client; };
46         derived_drop => { #[derive(Default)] pub struct Client { pub nickname: String } };
47         significant_drop => {
48             #[derive(Default)]
49             pub struct Client;
50             impl Drop for Client {
51                 fn drop(&mut self) {}
52             }
53         }
54     );
55 }