File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 33// edition:2018
44// aux-build:arc_wake.rs
55
6- #![ feature( async_await, async_closure ) ]
6+ #![ feature( async_await) ]
77
88extern crate arc_wake;
99
@@ -70,7 +70,7 @@ fn async_nonmove_block(x: u8) -> impl Future<Output = u8> {
7070 }
7171}
7272
73- // see async-closure.rs for async_closure
73+ // see async-closure.rs for async_closure + async_closure_in_unsafe_block
7474
7575async fn async_fn ( x : u8 ) -> u8 {
7676 wake_and_yield_once ( ) . await ;
Original file line number Diff line number Diff line change @@ -53,6 +53,21 @@ fn async_closure(x: u8) -> impl Future<Output = u8> {
5353 } ) ( x)
5454}
5555
56+ fn async_closure_in_unsafe_block ( x : u8 ) -> impl Future < Output = u8 > {
57+ ( unsafe {
58+ async move |x : u8 | unsafe_fn ( unsafe_async_fn ( x) . await )
59+ } ) ( x)
60+ }
61+
62+ async unsafe fn unsafe_async_fn ( x : u8 ) -> u8 {
63+ wake_and_yield_once ( ) . await ;
64+ x
65+ }
66+
67+ unsafe fn unsafe_fn ( x : u8 ) -> u8 {
68+ x
69+ }
70+
5671fn test_future_yields_once_then_returns < F , Fut > ( f : F )
5772where
5873 F : FnOnce ( u8 ) -> Fut ,
@@ -77,5 +92,6 @@ fn main() {
7792
7893 test ! {
7994 async_closure,
95+ async_closure_in_unsafe_block,
8096 }
8197}
Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ fn async_closure(x: u8) -> impl Future<Output = u8> {
7777 } ) ( x)
7878}
7979
80+ fn async_closure_in_unsafe_block ( x : u8 ) -> impl Future < Output = u8 > {
81+ ( unsafe {
82+ async move |x : u8 | unsafe_fn ( await ! ( unsafe_async_fn( x) ) )
83+ } ) ( x)
84+ }
85+
8086async fn async_fn ( x : u8 ) -> u8 {
8187 await ! ( wake_and_yield_once( ) ) ;
8288 x
@@ -193,6 +199,7 @@ fn main() {
193199 async_block,
194200 async_nonmove_block,
195201 async_closure,
202+ async_closure_in_unsafe_block,
196203 async_fn,
197204 generic_async_fn,
198205 async_fn_with_internal_borrow,
You can’t perform that action at this time.
0 commit comments