Skip to content

Commit 1829b4a

Browse files
committed
Add test case for different impl Futures
1 parent 3a0227b commit 1829b4a

File tree

2 files changed

+36
-3
lines changed

2 files changed

+36
-3
lines changed

src/test/ui/suggestions/match-prev-arm-needing-semi.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn extra_semicolon() {
1515

1616
async fn async_dummy() {} //~ NOTE the `Output` of this `async fn`'s found opaque type
1717
async fn async_dummy2() {} //~ NOTE the `Output` of this `async fn`'s found opaque type
18+
//~^ NOTE the `Output` of this `async fn`'s found opaque type
1819

1920
async fn async_extra_semicolon_same() {
2021
let _ = match true { //~ NOTE `match` arms have incompatible types
@@ -42,4 +43,14 @@ async fn async_extra_semicolon_different() {
4243
};
4344
}
4445

46+
async fn async_different_futures() {
47+
let _ = match true { //~ NOTE `match` arms have incompatible types
48+
true => async_dummy(), //~ NOTE this is found to be
49+
false => async_dummy2(), //~ ERROR `match` arms have incompatible types
50+
//~^ NOTE expected opaque type, found a different opaque type
51+
//~| NOTE expected type `impl Future`
52+
//~| NOTE distinct uses of `impl Trait` result in different opaque types
53+
};
54+
}
55+
4556
fn main() {}

src/test/ui/suggestions/match-prev-arm-needing-semi.stderr

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: `match` arms have incompatible types
2-
--> $DIR/match-prev-arm-needing-semi.rs:25:18
2+
--> $DIR/match-prev-arm-needing-semi.rs:26:18
33
|
44
LL | async fn async_dummy() {}
55
| - the `Output` of this `async fn`'s found opaque type
@@ -30,7 +30,7 @@ LL | false => async_dummy().await,
3030
| ^^^^^^
3131

3232
error[E0308]: `match` arms have incompatible types
33-
--> $DIR/match-prev-arm-needing-semi.rs:38:18
33+
--> $DIR/match-prev-arm-needing-semi.rs:39:18
3434
|
3535
LL | async fn async_dummy2() {}
3636
| - the `Output` of this `async fn`'s found opaque type
@@ -60,6 +60,28 @@ help: consider `await`ing on the `Future`
6060
LL | false => async_dummy2().await,
6161
| ^^^^^^
6262

63+
error[E0308]: `match` arms have incompatible types
64+
--> $DIR/match-prev-arm-needing-semi.rs:49:18
65+
|
66+
LL | async fn async_dummy2() {}
67+
| - the `Output` of this `async fn`'s found opaque type
68+
...
69+
LL | let _ = match true {
70+
| _____________-
71+
LL | | true => async_dummy(),
72+
| | ------------- this is found to be of type `impl Future`
73+
LL | | false => async_dummy2(),
74+
| | ^^^^^^^^^^^^^^ expected opaque type, found a different opaque type
75+
LL | |
76+
LL | |
77+
LL | |
78+
LL | | };
79+
| |_____- `match` arms have incompatible types
80+
|
81+
= note: expected type `impl Future` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>)
82+
found opaque type `impl Future` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:17:25>)
83+
= note: distinct uses of `impl Trait` result in different opaque types
84+
6385
error[E0308]: `match` arms have incompatible types
6486
--> $DIR/match-prev-arm-needing-semi.rs:11:18
6587
|
@@ -79,6 +101,6 @@ LL | |
79101
LL | | };
80102
| |_____- `match` arms have incompatible types
81103

82-
error: aborting due to 3 previous errors
104+
error: aborting due to 4 previous errors
83105

84106
For more information about this error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)