diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2020-10-21 19:43:15 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2020-10-23 08:06:13 -0700 |
| commit | 671d7c4afb36a7dcedf9ec8a6f3ef00c19bfc260 (patch) | |
| tree | 09e30ca245dd37c3a4c0977935e0441da485910c /src | |
| parent | a4ee3ca1e4f1177516139a4704456958c7d08c91 (diff) | |
| download | rust-671d7c4afb36a7dcedf9ec8a6f3ef00c19bfc260.tar.gz rust-671d7c4afb36a7dcedf9ec8a6f3ef00c19bfc260.zip | |
Account for possible boxable `impl Future` in semicolon removal suggestions
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/suggestions/match-prev-arm-needing-semi.rs | 15 | ||||
| -rw-r--r-- | src/test/ui/suggestions/match-prev-arm-needing-semi.stderr | 37 |
2 files changed, 48 insertions, 4 deletions
diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs index d8d6de4bf55..9704242e105 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.rs +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.rs @@ -14,6 +14,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 async fn async_extra_semicolon_same() { let _ = match true { //~ NOTE `match` arms have incompatible types @@ -28,5 +29,17 @@ async fn async_extra_semicolon_same() { }; } -fn main() {} +async fn async_extra_semicolon_different() { + let _ = match true { //~ NOTE `match` arms have incompatible types + true => { + async_dummy(); //~ NOTE this is found to be + //~^ HELP consider removing this semicolon + } + false => async_dummy2(), //~ ERROR `match` arms have incompatible types + //~^ NOTE expected `()`, found opaque type + //~| NOTE expected type `()` + //~| HELP consider `await`ing on the `Future` + }; +} +fn main() {} diff --git a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr index e242a018843..00b02fbc007 100644 --- a/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr +++ b/src/test/ui/suggestions/match-prev-arm-needing-semi.stderr @@ -1,5 +1,5 @@ error[E0308]: `match` arms have incompatible types - --> $DIR/match-prev-arm-needing-semi.rs:24:18 + --> $DIR/match-prev-arm-needing-semi.rs:25:18 | LL | async fn async_dummy() {} | - the `Output` of this `async fn`'s found opaque type @@ -20,7 +20,7 @@ LL | | }; | = note: expected type `()` found opaque type `impl Future` -help: consider removing this semicolon +help: consider removing this semicolon and boxing the expression | LL | async_dummy() | -- @@ -30,6 +30,37 @@ LL | false => async_dummy().await, | ^^^^^^ error[E0308]: `match` arms have incompatible types + --> $DIR/match-prev-arm-needing-semi.rs:38:18 + | +LL | async fn async_dummy2() {} + | - the `Output` of this `async fn`'s found opaque type +... +LL | let _ = match true { + | _____________- +LL | | true => { +LL | | async_dummy(); + | | -------------- this is found to be of type `()` +LL | | +LL | | } +LL | | false => async_dummy2(), + | | ^^^^^^^^^^^^^^ expected `()`, found opaque type +... | +LL | | +LL | | }; + | |_____- `match` arms have incompatible types + | + = note: expected type `()` + found opaque type `impl Future` +help: consider removing this semicolon and boxing the expression + | +LL | async_dummy() + | -- +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:11:18 | LL | let _ = match true { @@ -48,6 +79,6 @@ LL | | LL | | }; | |_____- `match` arms have incompatible types -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0308`. |
