about summary refs log tree commit diff
path: root/tests/ui/async-await/async-closures/constrained-but-no-upvars-yet.rs
blob: 1acbf0311b3aab45c62cbfef54f9855e9e2b82a0 (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
//@ edition: 2021
//@ build-pass
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[next] compile-flags: -Znext-solver

#![feature(async_closure)]

fn constrain<T: AsyncFnOnce()>(t: T) -> T {
    t
}

fn call_once<T>(f: impl FnOnce() -> T) -> T {
    f()
}

async fn async_call_once<T>(f: impl AsyncFnOnce() -> T) -> T {
    f().await
}

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

    let c = constrain(async || {});
    async_call_once(c);
}