]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issue-72470-llvm-dominate.rs
Auto merge of #81507 - weiznich:add_diesel_to_cargo_test, r=Mark-Simulacrum
[rust.git] / src / test / ui / issue-72470-llvm-dominate.rs
1 // compile-flags: -C opt-level=3
2 // aux-build: issue-72470-lib.rs
3 // edition:2018
4 // build-pass
5
6 // Regression test for issue #72470, using the minimization
7 // in https://github.com/jonas-schievink/llvm-error
8
9 extern crate issue_72470_lib;
10
11 use std::future::Future;
12 use std::pin::Pin;
13 use std::sync::Mutex;
14 use std::task::Poll::{Pending, Ready};
15
16 #[allow(dead_code)]
17 enum Msg {
18     A(Vec<()>),
19     B,
20 }
21
22 #[allow(dead_code)]
23 enum Out {
24     _0(Option<Msg>),
25     Disabled,
26 }
27
28 #[allow(unused_must_use)]
29 fn main() {
30     let mut rx = issue_72470_lib::unbounded_channel::<Msg>();
31     let entity = Mutex::new(());
32     issue_72470_lib::run(async move {
33         {
34             let output = {
35                 let mut fut = rx.recv();
36                 issue_72470_lib::poll_fn(|cx| {
37                     loop {
38                         let fut = unsafe { Pin::new_unchecked(&mut fut) };
39                         let out = match fut.poll(cx) {
40                             Ready(out) => out,
41                             Pending => {
42                                 break;
43                             }
44                         };
45                         #[allow(unused_variables)]
46                         match &out {
47                             Some(_msg) => {}
48                             _ => break,
49                         }
50                         return Ready(Out::_0(out));
51                     }
52                     Ready(Out::_0(None))
53                 })
54                 .await
55             };
56             match output {
57                 Out::_0(Some(_msg)) => {
58                     entity.lock();
59                 }
60                 Out::_0(None) => unreachable!(),
61                 _ => unreachable!(),
62             }
63         }
64         entity.lock();
65     });
66 }