summaryrefslogtreecommitdiffstats
path: root/src/test/ui/async-await/issue-72470-llvm-dominate.rs
blob: 5bb69a0730525f3d69de586daae62f467a9793df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// compile-flags: -C opt-level=3
// aux-build: issue-72470-lib.rs
// edition:2018
// build-pass

// Regression test for issue #72470, using the minimization
// in https://github.com/jonas-schievink/llvm-error

extern crate issue_72470_lib;

use std::future::Future;
use std::pin::Pin;
use std::sync::Mutex;
use std::task::Poll::{Pending, Ready};

#[allow(dead_code)]
enum Msg {
    A(Vec<()>),
    B,
}

#[allow(dead_code)]
enum Out {
    _0(Option<Msg>),
    Disabled,
}

#[allow(unused_must_use)]
fn main() {
    let mut rx = issue_72470_lib::unbounded_channel::<Msg>();
    let entity = Mutex::new(());
    issue_72470_lib::run(async move {
        {
            let output = {
                let mut fut = rx.recv();
                issue_72470_lib::poll_fn(|cx| {
                    loop {
                        let fut = unsafe { Pin::new_unchecked(&mut fut) };
                        let out = match fut.poll(cx) {
                            Ready(out) => out,
                            Pending => {
                                break;
                            }
                        };
                        #[allow(unused_variables)]
                        match &out {
                            Some(_msg) => {}
                            _ => break,
                        }
                        return Ready(Out::_0(out));
                    }
                    Ready(Out::_0(None))
                })
                .await
            };
            match output {
                Out::_0(Some(_msg)) => {
                    entity.lock();
                }
                Out::_0(None) => unreachable!(),
                _ => unreachable!(),
            }
        }
        entity.lock();
    });
}