Skip to content

Commit

Permalink
Add test case for different impl Futures
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Oct 23, 2020
1 parent 3a0227b commit 1829b4a
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/test/ui/suggestions/match-prev-arm-needing-semi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fn extra_semicolon() {

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

async fn async_extra_semicolon_same() {
let _ = match true { //~ NOTE `match` arms have incompatible types
Expand Down Expand Up @@ -42,4 +43,14 @@ async fn async_extra_semicolon_different() {
};
}

async fn async_different_futures() {
let _ = match true { //~ NOTE `match` arms have incompatible types
true => async_dummy(), //~ NOTE this is found to be
false => async_dummy2(), //~ ERROR `match` arms have incompatible types
//~^ NOTE expected opaque type, found a different opaque type
//~| NOTE expected type `impl Future`
//~| NOTE distinct uses of `impl Trait` result in different opaque types
};
}

fn main() {}
28 changes: 25 additions & 3 deletions src/test/ui/suggestions/match-prev-arm-needing-semi.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: `match` arms have incompatible types
--> $DIR/match-prev-arm-needing-semi.rs:25:18
--> $DIR/match-prev-arm-needing-semi.rs:26:18
|
LL | async fn async_dummy() {}
| - the `Output` of this `async fn`'s found opaque type
Expand Down Expand Up @@ -30,7 +30,7 @@ LL | false => async_dummy().await,
| ^^^^^^

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

error[E0308]: `match` arms have incompatible types
--> $DIR/match-prev-arm-needing-semi.rs:49:18
|
LL | async fn async_dummy2() {}
| - the `Output` of this `async fn`'s found opaque type
...
LL | let _ = match true {
| _____________-
LL | | true => async_dummy(),
| | ------------- this is found to be of type `impl Future`
LL | | false => async_dummy2(),
| | ^^^^^^^^^^^^^^ expected opaque type, found a different opaque type
LL | |
LL | |
LL | |
LL | | };
| |_____- `match` arms have incompatible types
|
= note: expected type `impl Future` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:16:24>)
found opaque type `impl Future` (opaque type at <$DIR/match-prev-arm-needing-semi.rs:17:25>)
= note: distinct uses of `impl Trait` result in different opaque types

error[E0308]: `match` arms have incompatible types
--> $DIR/match-prev-arm-needing-semi.rs:11:18
|
Expand All @@ -79,6 +101,6 @@ LL | |
LL | | };
| |_____- `match` arms have incompatible types

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

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

0 comments on commit 1829b4a

Please sign in to comment.