diff options
| author | Michael Goulet <michael@errs.io> | 2024-02-06 20:51:56 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-02-08 15:46:07 +0000 |
| commit | 9322882adeb232af46ecd1400ce2af4a96347425 (patch) | |
| tree | 32272138bb4fc864df15c862ebe956c020d883c1 | |
| parent | 3bb384aad6e7f61a0b4b8c604206e78ffa418df4 (diff) | |
| download | rust-9322882adeb232af46ecd1400ce2af4a96347425.tar.gz rust-9322882adeb232af46ecd1400ce2af4a96347425.zip | |
Add a couple more tests
| -rw-r--r-- | tests/ui/async-await/async-closures/once.rs | 22 | ||||
| -rw-r--r-- | tests/ui/async-await/async-closures/refd.rs | 18 |
2 files changed, 40 insertions, 0 deletions
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 00000000000..a1c56c5de6a --- /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<F: Future>(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 00000000000..7c61ff2d9bd --- /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 + }); +} |
