File tree 3 files changed +25
-2
lines changed
3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 3
3
// edition:2018
4
4
// aux-build:arc_wake.rs
5
5
6
- #![ feature( async_await, async_closure ) ]
6
+ #![ feature( async_await) ]
7
7
8
8
extern crate arc_wake;
9
9
@@ -70,7 +70,7 @@ fn async_nonmove_block(x: u8) -> impl Future<Output = u8> {
70
70
}
71
71
}
72
72
73
- // see async-closure.rs for async_closure
73
+ // see async-closure.rs for async_closure + async_closure_in_unsafe_block
74
74
75
75
async fn async_fn ( x : u8 ) -> u8 {
76
76
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> {
53
53
} ) ( x)
54
54
}
55
55
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
+
56
71
fn test_future_yields_once_then_returns < F , Fut > ( f : F )
57
72
where
58
73
F : FnOnce ( u8 ) -> Fut ,
@@ -77,5 +92,6 @@ fn main() {
77
92
78
93
test ! {
79
94
async_closure,
95
+ async_closure_in_unsafe_block,
80
96
}
81
97
}
Original file line number Diff line number Diff line change @@ -77,6 +77,12 @@ fn async_closure(x: u8) -> impl Future<Output = u8> {
77
77
} ) ( x)
78
78
}
79
79
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
+
80
86
async fn async_fn ( x : u8 ) -> u8 {
81
87
await ! ( wake_and_yield_once( ) ) ;
82
88
x
@@ -193,6 +199,7 @@ fn main() {
193
199
async_block,
194
200
async_nonmove_block,
195
201
async_closure,
202
+ async_closure_in_unsafe_block,
196
203
async_fn,
197
204
generic_async_fn,
198
205
async_fn_with_internal_borrow,
You can’t perform that action at this time.
0 commit comments