Skip to content

Commit 2bafb8b

Browse files
committed
Add a test for an async function.
1 parent 3f1d5ee commit 2bafb8b

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

tests/ui/async_yields_async.fixed

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ fn custom_future_type_ctor() -> CustomFutureType {
2222
CustomFutureType
2323
}
2424

25+
async fn f() -> CustomFutureType {
26+
// Don't warn for functions since you have to explicitly declare their
27+
// return types.
28+
CustomFutureType
29+
}
30+
2531
#[rustfmt::skip]
2632
fn main() {
2733
let _f = {
@@ -58,4 +64,5 @@ fn main() {
5864
CustomFutureType.await
5965
};
6066
let _n = async || custom_future_type_ctor();
67+
let _o = async || f();
6168
}

tests/ui/async_yields_async.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ fn custom_future_type_ctor() -> CustomFutureType {
2222
CustomFutureType
2323
}
2424

25+
async fn f() -> CustomFutureType {
26+
// Don't warn for functions since you have to explicitly declare their
27+
// return types.
28+
CustomFutureType
29+
}
30+
2531
#[rustfmt::skip]
2632
fn main() {
2733
let _f = {
@@ -58,4 +64,5 @@ fn main() {
5864
CustomFutureType
5965
};
6066
let _n = async || custom_future_type_ctor();
67+
let _o = async || f();
6168
}

tests/ui/async_yields_async.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: an async construct yields a type which is itself awaitable
2-
--> $DIR/async_yields_async.rs:34:9
2+
--> $DIR/async_yields_async.rs:40:9
33
|
44
LL | let _h = async {
55
| ____________________-
@@ -20,7 +20,7 @@ LL | }.await
2020
|
2121

2222
error: an async construct yields a type which is itself awaitable
23-
--> $DIR/async_yields_async.rs:39:9
23+
--> $DIR/async_yields_async.rs:45:9
2424
|
2525
LL | let _i = async {
2626
| ____________________-
@@ -33,7 +33,7 @@ LL | | };
3333
| |_____- outer async construct
3434

3535
error: an async construct yields a type which is itself awaitable
36-
--> $DIR/async_yields_async.rs:45:9
36+
--> $DIR/async_yields_async.rs:51:9
3737
|
3838
LL | let _j = async || {
3939
| _______________________-
@@ -53,7 +53,7 @@ LL | }.await
5353
|
5454

5555
error: an async construct yields a type which is itself awaitable
56-
--> $DIR/async_yields_async.rs:50:9
56+
--> $DIR/async_yields_async.rs:56:9
5757
|
5858
LL | let _k = async || {
5959
| _______________________-
@@ -66,7 +66,7 @@ LL | | };
6666
| |_____- outer async construct
6767

6868
error: an async construct yields a type which is itself awaitable
69-
--> $DIR/async_yields_async.rs:52:23
69+
--> $DIR/async_yields_async.rs:58:23
7070
|
7171
LL | let _l = async || CustomFutureType;
7272
| ^^^^^^^^^^^^^^^^
@@ -76,7 +76,7 @@ LL | let _l = async || CustomFutureType;
7676
| help: consider awaiting this value: `CustomFutureType.await`
7777

7878
error: an async construct yields a type which is itself awaitable
79-
--> $DIR/async_yields_async.rs:58:9
79+
--> $DIR/async_yields_async.rs:64:9
8080
|
8181
LL | let _m = async || {
8282
| _______________________-

0 commit comments

Comments
 (0)