diff options
Diffstat (limited to 'tests/ui/async-await/issue-72470-llvm-dominate.rs')
-rw-r--r-- | tests/ui/async-await/issue-72470-llvm-dominate.rs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/ui/async-await/issue-72470-llvm-dominate.rs b/tests/ui/async-await/issue-72470-llvm-dominate.rs new file mode 100644 index 000000000..5bb69a073 --- /dev/null +++ b/tests/ui/async-await/issue-72470-llvm-dominate.rs @@ -0,0 +1,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(); + }); +} |