Skip to content

Commit 1574c2d

Browse files
committed
align async-await.rs and await-macro.rs with one another
1 parent e31911e commit 1574c2d

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/test/ui/async-await/async-await.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// edition:2018
44
// aux-build:arc_wake.rs
55

6-
#![feature(async_await)]
6+
#![feature(async_await, async_closure)]
77

88
extern crate arc_wake;
99

@@ -70,6 +70,13 @@ fn async_nonmove_block(x: u8) -> impl Future<Output = u8> {
7070
}
7171
}
7272

73+
fn async_closure(x: u8) -> impl Future<Output = u8> {
74+
(async move |x: u8| -> u8 {
75+
wake_and_yield_once().await;
76+
x
77+
})(x)
78+
}
79+
7380
async fn async_fn(x: u8) -> u8 {
7481
wake_and_yield_once().await;
7582
x
@@ -173,6 +180,7 @@ fn main() {
173180
test! {
174181
async_block,
175182
async_nonmove_block,
183+
async_closure,
176184
async_fn,
177185
generic_async_fn,
178186
async_fn_with_internal_borrow,

src/test/ui/async-await/await-macro.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ trait Bar {
134134
}
135135

136136
impl Foo {
137-
async fn async_method(x: u8) -> u8 {
137+
async fn async_assoc_item(x: u8) -> u8 {
138138
unsafe {
139139
await!(unsafe_async_fn(x))
140140
}
141141
}
142+
143+
async unsafe fn async_unsafe_assoc_item(x: u8) -> u8 {
144+
await!(unsafe_async_fn(x))
145+
}
142146
}
143147

144148
fn test_future_yields_once_then_returns<F, Fut>(f: F)
@@ -180,12 +184,17 @@ fn main() {
180184
async_fn,
181185
generic_async_fn,
182186
async_fn_with_internal_borrow,
183-
Foo::async_method,
187+
Foo::async_assoc_item,
184188
|x| {
185189
async move {
186190
unsafe { await!(unsafe_async_fn(x)) }
187191
}
188192
},
193+
|x| {
194+
async move {
195+
unsafe { await!(Foo::async_unsafe_assoc_item(x)) }
196+
}
197+
},
189198
}
190199
test_with_borrow! {
191200
async_block_with_borrow_named_lifetime,

0 commit comments

Comments
 (0)