mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
Add a couple more tests
This commit is contained in:
parent
3bb384aad6
commit
9322882ade
22
tests/ui/async-await/async-closures/once.rs
Normal file
22
tests/ui/async-await/async-closures/once.rs
Normal file
@ -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
|
||||
});
|
||||
}
|
18
tests/ui/async-await/async-closures/refd.rs
Normal file
18
tests/ui/async-await/async-closures/refd.rs
Normal file
@ -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
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user