@@ -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
@@ -127,18 +133,34 @@ async unsafe fn unsafe_async_fn(x: u8) -> u8 {
127
133
x
128
134
}
129
135
136
+ unsafe fn unsafe_fn ( x : u8 ) -> u8 {
137
+ x
138
+ }
139
+
140
+ fn async_block_in_unsafe_block ( x : u8 ) -> impl Future < Output = u8 > {
141
+ unsafe {
142
+ async move {
143
+ unsafe_fn ( await ! ( unsafe_async_fn( x) ) )
144
+ }
145
+ }
146
+ }
147
+
130
148
struct Foo ;
131
149
132
150
trait Bar {
133
151
fn foo ( ) { }
134
152
}
135
153
136
154
impl Foo {
137
- async fn async_method ( x : u8 ) -> u8 {
155
+ async fn async_assoc_item ( x : u8 ) -> u8 {
138
156
unsafe {
139
157
await ! ( unsafe_async_fn( x) )
140
158
}
141
159
}
160
+
161
+ async unsafe fn async_unsafe_assoc_item ( x : u8 ) -> u8 {
162
+ await ! ( unsafe_async_fn( x) )
163
+ }
142
164
}
143
165
144
166
fn test_future_yields_once_then_returns < F , Fut > ( f : F )
@@ -177,15 +199,22 @@ fn main() {
177
199
async_block,
178
200
async_nonmove_block,
179
201
async_closure,
202
+ async_closure_in_unsafe_block,
180
203
async_fn,
181
204
generic_async_fn,
182
205
async_fn_with_internal_borrow,
183
- Foo :: async_method,
206
+ async_block_in_unsafe_block,
207
+ Foo :: async_assoc_item,
184
208
|x| {
185
209
async move {
186
210
unsafe { await !( unsafe_async_fn( x) ) }
187
211
}
188
212
} ,
213
+ |x| {
214
+ async move {
215
+ unsafe { await !( Foo :: async_unsafe_assoc_item( x) ) }
216
+ }
217
+ } ,
189
218
}
190
219
test_with_borrow ! {
191
220
async_block_with_borrow_named_lifetime,
0 commit comments