rust/tests/crashes/124020.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

34 lines
752 B
Rust
Raw Normal View History

2024-04-16 18:01:07 -05:00
//@ known-bug: #124020
//@ compile-flags: -Zpolymorphize=on --edition=2018 --crate-type=lib
#![feature(async_closure, noop_waker, async_fn_traits)]
use std::future::Future;
use std::pin::pin;
use std::task::*;
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
let mut fut = pin!(fut);
let ctx = &mut Context::from_waker(Waker::noop());
loop {
match fut.as_mut().poll(ctx) {
Poll::Pending => {}
Poll::Ready(t) => break t,
}
}
}
async fn call_once(f: impl async FnOnce(DropMe)) {
f(DropMe("world")).await;
}
struct DropMe(&'static str);
pub fn future() {
block_on(async {
let async_closure = async move |a: DropMe| {};
call_once(async_closure).await;
});
}