File tree 4 files changed +36
-9
lines changed
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;
8
8
9
9
fn main ( ) {
10
10
block_on:: block_on ( async {
11
- let x = async || { } ;
12
-
13
11
async fn needs_async_fn_once ( x : impl async FnOnce ( ) ) {
14
12
x ( ) . await ;
15
13
}
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 ;
17
21
} ) ;
18
22
}
Original file line number Diff line number Diff line change 2
2
//@ edition:2021
3
3
//@ build-pass
4
4
5
- #![ feature( async_closure) ]
5
+ #![ feature( async_closure, async_fn_traits ) ]
6
6
7
7
extern crate block_on;
8
8
@@ -15,7 +15,11 @@ fn main() {
15
15
c ( ) . await ;
16
16
c ( ) . await ;
17
17
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) ) ;
20
24
} ) ;
21
25
}
Original file line number Diff line number Diff line change 2
2
//@ edition:2021
3
3
//@ build-pass
4
4
5
- // check that `&{async-closure}` implements `AsyncFn`.
6
-
7
5
#![ feature( async_closure) ]
8
6
9
7
extern crate block_on;
@@ -13,6 +11,15 @@ struct NoCopy;
13
11
fn main ( ) {
14
12
block_on:: block_on ( async {
15
13
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 ;
17
24
} ) ;
18
25
}
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