about summary refs log tree commit diff
path: root/tests/ui/async-await/async-closures/async-future-out-must-be-sized.rs
blob: e5d70e30eb5f692189f5c95f76f474aeb15ed0b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//@ edition: 2021

// Ensure that the output of a `fn` pointer that implements `AsyncFn*` is `Sized`,
// like other built-in impls of an fn pointer, like `Fn*`.

use std::future::Future;

fn foo() -> fn() -> dyn Future<Output = ()> {
    todo!()
}

async fn is_async_fn(f: impl AsyncFn()) {
    f().await;
}

fn main() {
    is_async_fn(foo());
    //~^ ERROR the size for values of type `dyn Future<Output = ()>` cannot be known at compilation time
    //~| ERROR the size for values of type `dyn Future<Output = ()>` cannot be known at compilation time
}