Skip to content

Commit c8e3f35

Browse files
Flesh out a few more tests
1 parent 2252ff7 commit c8e3f35

File tree

4 files changed

+36
-9
lines changed

4 files changed

+36
-9
lines changed

tests/ui/async-await/async-closures/async-fn-once-for-async-fn.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@ extern crate block_on;
88

99
fn main() {
1010
block_on::block_on(async {
11-
let x = async || {};
12-
1311
async fn needs_async_fn_once(x: impl async FnOnce()) {
1412
x().await;
1513
}
16-
needs_async_fn_once(x).await;
14+
15+
needs_async_fn_once(async || {}).await;
16+
17+
needs_async_fn_once(|| async {}).await;
18+
19+
async fn foo() {}
20+
needs_async_fn_once(foo).await;
1721
});
1822
}

tests/ui/async-await/async-closures/move-is-async-fn.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//@ edition:2021
33
//@ build-pass
44

5-
#![feature(async_closure)]
5+
#![feature(async_closure, async_fn_traits)]
66

77
extern crate block_on;
88

@@ -15,7 +15,11 @@ fn main() {
1515
c().await;
1616
c().await;
1717

18-
fn is_static<T: 'static>(_: T) {}
19-
is_static(c);
18+
fn is_static<T: 'static>(_: &T) {}
19+
is_static(&c);
20+
21+
// Check that `<{async fn} as AsyncFnOnce>::CallOnceFuture` owns its captures.
22+
fn call_once<F: async FnOnce()>(f: F) -> F::CallOnceFuture { f() }
23+
is_static(&call_once(c));
2024
});
2125
}

tests/ui/async-await/async-closures/refd.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
//@ edition:2021
33
//@ build-pass
44

5-
// check that `&{async-closure}` implements `AsyncFn`.
6-
75
#![feature(async_closure)]
86

97
extern crate block_on;
@@ -13,6 +11,15 @@ struct NoCopy;
1311
fn main() {
1412
block_on::block_on(async {
1513
async fn call_once(x: impl async Fn()) { x().await }
16-
call_once(&async || {}).await
14+
15+
// check that `&{async-closure}` implements `async Fn`.
16+
call_once(&async || {}).await;
17+
18+
// check that `&{closure}` implements `async Fn`.
19+
call_once(&|| async {}).await;
20+
21+
// check that `&fndef` implements `async Fn`.
22+
async fn foo() {}
23+
call_once(&foo).await;
1724
});
1825
}
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ edition:2018
2+
//@ revisions: current next
3+
//@[next] compile-flags: -Znext-solver
4+
//@ check-pass
5+
6+
#![feature(async_closure, unboxed_closures, async_fn_traits)]
7+
8+
fn project<F: async Fn<()>>(_: F) -> Option<F::Output> { None }
9+
10+
fn main() {
11+
let x: Option<i32> = project(|| async { 1i32 });
12+
}

0 commit comments

Comments
 (0)