Flesh out a few more tests
This commit is contained in:
parent
2252ff7302
commit
c8e3f35eb6
@ -8,11 +8,15 @@
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
block_on::block_on(async {
|
block_on::block_on(async {
|
||||||
let x = async || {};
|
|
||||||
|
|
||||||
async fn needs_async_fn_once(x: impl async FnOnce()) {
|
async fn needs_async_fn_once(x: impl async FnOnce()) {
|
||||||
x().await;
|
x().await;
|
||||||
}
|
}
|
||||||
needs_async_fn_once(x).await;
|
|
||||||
|
needs_async_fn_once(async || {}).await;
|
||||||
|
|
||||||
|
needs_async_fn_once(|| async {}).await;
|
||||||
|
|
||||||
|
async fn foo() {}
|
||||||
|
needs_async_fn_once(foo).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//@ edition:2021
|
//@ edition:2021
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
|
||||||
#![feature(async_closure)]
|
#![feature(async_closure, async_fn_traits)]
|
||||||
|
|
||||||
extern crate block_on;
|
extern crate block_on;
|
||||||
|
|
||||||
@ -15,7 +15,11 @@ fn main() {
|
|||||||
c().await;
|
c().await;
|
||||||
c().await;
|
c().await;
|
||||||
|
|
||||||
fn is_static<T: 'static>(_: T) {}
|
fn is_static<T: 'static>(_: &T) {}
|
||||||
is_static(c);
|
is_static(&c);
|
||||||
|
|
||||||
|
// Check that `<{async fn} as AsyncFnOnce>::CallOnceFuture` owns its captures.
|
||||||
|
fn call_once<F: async FnOnce()>(f: F) -> F::CallOnceFuture { f() }
|
||||||
|
is_static(&call_once(c));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
//@ edition:2021
|
//@ edition:2021
|
||||||
//@ build-pass
|
//@ build-pass
|
||||||
|
|
||||||
// check that `&{async-closure}` implements `AsyncFn`.
|
|
||||||
|
|
||||||
#![feature(async_closure)]
|
#![feature(async_closure)]
|
||||||
|
|
||||||
extern crate block_on;
|
extern crate block_on;
|
||||||
@ -13,6 +11,15 @@
|
|||||||
fn main() {
|
fn main() {
|
||||||
block_on::block_on(async {
|
block_on::block_on(async {
|
||||||
async fn call_once(x: impl async Fn()) { x().await }
|
async fn call_once(x: impl async Fn()) { x().await }
|
||||||
call_once(&async || {}).await
|
|
||||||
|
// check that `&{async-closure}` implements `async Fn`.
|
||||||
|
call_once(&async || {}).await;
|
||||||
|
|
||||||
|
// check that `&{closure}` implements `async Fn`.
|
||||||
|
call_once(&|| async {}).await;
|
||||||
|
|
||||||
|
// check that `&fndef` implements `async Fn`.
|
||||||
|
async fn foo() {}
|
||||||
|
call_once(&foo).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
12
tests/ui/async-await/async-fn/project.rs
Normal file
12
tests/ui/async-await/async-fn/project.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
//@ edition:2018
|
||||||
|
//@ revisions: current next
|
||||||
|
//@[next] compile-flags: -Znext-solver
|
||||||
|
//@ check-pass
|
||||||
|
|
||||||
|
#![feature(async_closure, unboxed_closures, async_fn_traits)]
|
||||||
|
|
||||||
|
fn project<F: async Fn<()>>(_: F) -> Option<F::Output> { None }
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: Option<i32> = project(|| async { 1i32 });
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user