2024-02-06 14:51:56 -06:00
|
|
|
//@ aux-build:block-on.rs
|
|
|
|
//@ edition:2021
|
|
|
|
//@ build-pass
|
2024-02-26 17:43:10 -06:00
|
|
|
//@ revisions: current next
|
2024-03-10 20:18:41 -05:00
|
|
|
//@ ignore-compare-mode-next-solver (explicit revisions)
|
2024-02-26 17:43:10 -06:00
|
|
|
//@[next] compile-flags: -Znext-solver
|
2024-02-06 14:51:56 -06:00
|
|
|
|
|
|
|
#![feature(async_closure)]
|
|
|
|
|
|
|
|
use std::future::Future;
|
|
|
|
|
|
|
|
extern crate block_on;
|
|
|
|
|
2024-02-26 17:43:10 -06:00
|
|
|
// Check that async closures always implement `FnOnce`
|
2024-02-06 14:51:56 -06:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
block_on::block_on(async {
|
2024-02-26 17:43:10 -06:00
|
|
|
async fn call_once<F: Future>(x: impl FnOnce(&'static str) -> F) -> F::Output {
|
2024-02-06 14:51:56 -06:00
|
|
|
x("hello, world").await
|
|
|
|
}
|
|
|
|
call_once(async |x: &'static str| {
|
|
|
|
println!("hello, {x}");
|
|
|
|
}).await
|
|
|
|
});
|
|
|
|
}
|