From b093e0cbb227dc9712526fd18d9a532b7fe2c6e3 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Tue, 6 Feb 2024 20:51:56 +0000 Subject: [PATCH] Add a couple more tests --- tests/ui/async-await/async-closures/once.rs | 22 +++++++++++++++++++++ tests/ui/async-await/async-closures/refd.rs | 18 +++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/ui/async-await/async-closures/once.rs create mode 100644 tests/ui/async-await/async-closures/refd.rs diff --git a/tests/ui/async-await/async-closures/once.rs b/tests/ui/async-await/async-closures/once.rs new file mode 100644 index 0000000000000..a1c56c5de6afd --- /dev/null +++ b/tests/ui/async-await/async-closures/once.rs @@ -0,0 +1,22 @@ +// aux-build:block-on.rs +// edition:2021 +// build-pass + +#![feature(async_closure)] + +use std::future::Future; + +extern crate block_on; + +struct NoCopy; + +fn main() { + block_on::block_on(async { + async fn call_once(x: impl Fn(&'static str) -> F) -> F::Output { + x("hello, world").await + } + call_once(async |x: &'static str| { + println!("hello, {x}"); + }).await + }); +} diff --git a/tests/ui/async-await/async-closures/refd.rs b/tests/ui/async-await/async-closures/refd.rs new file mode 100644 index 0000000000000..7c61ff2d9bd87 --- /dev/null +++ b/tests/ui/async-await/async-closures/refd.rs @@ -0,0 +1,18 @@ +// aux-build:block-on.rs +// edition:2021 +// build-pass + +// check that `&{async-closure}` implements `AsyncFn`. + +#![feature(async_closure)] + +extern crate block_on; + +struct NoCopy; + +fn main() { + block_on::block_on(async { + async fn call_once(x: impl async Fn()) { x().await } + call_once(&async || {}).await + }); +}