This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +36
-9
lines changed Expand file tree Collapse file tree 4 files changed +36
-9
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,15 @@ extern crate block_on;
88
99fn 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}
Original file line number Diff line number Diff line change 22//@ edition:2021
33//@ build-pass
44
5- #![ feature( async_closure) ]
5+ #![ feature( async_closure, async_fn_traits ) ]
66
77extern 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}
Original file line number Diff line number Diff line change 22//@ edition:2021
33//@ build-pass
44
5- // check that `&{async-closure}` implements `AsyncFn`.
6-
75#![ feature( async_closure) ]
86
97extern crate block_on;
@@ -13,6 +11,15 @@ struct NoCopy;
1311fn 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}
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments