about summary refs log tree commit diff
path: root/tests/ui/async-await/async-closures/inline-body.rs
blob: 3f1b9c266016de88ca605a6f3cda3f32857ff42b (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
//@ edition: 2021
//@ compile-flags: -Zinline-mir
//@ build-pass

// Ensure that we don't hit a Steal ICE because we forgot to ensure
// `mir_inliner_callees` for the synthetic by-move coroutine body since
// its def-id wasn't previously being considered.

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<T>(f: impl AsyncFnOnce() -> T) -> T {
    f().await
}

fn main() {
    let c = async || {};
    block_on(call_once(c));
}