about summary refs log tree commit diff
path: root/tests/ui/async-await/async-closures/refd.rs
blob: ae8a10a530ae3035a9f56d4dea27d0018dcb44a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//@ aux-build:block-on.rs
//@ edition:2021
//@ build-pass

extern crate block_on;

struct NoCopy;

fn main() {
    block_on::block_on(async {
        async fn call_once(x: impl AsyncFn()) { x().await }

        // check that `&{async-closure}` implements `AsyncFn`.
        call_once(&async || {}).await;

        // check that `&{closure}` implements `AsyncFn`.
        call_once(&|| async {}).await;

        // check that `&fndef` implements `AsyncFn`.
        async fn foo() {}
        call_once(&foo).await;
    });
}