Suggest await on cases involving infer
This commit is contained in:
parent
93542a8240
commit
33c443dd9d
3 changed files with 85 additions and 4 deletions
|
|
@ -54,4 +54,21 @@ async fn suggest_await_on_match_expr() {
|
|||
};
|
||||
}
|
||||
|
||||
async fn dummy_result() -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
async fn suggest_await_in_generic_pattern() {
|
||||
match dummy_result() {
|
||||
//~^ HELP consider `await`ing on the `Future`
|
||||
//~| HELP consider `await`ing on the `Future`
|
||||
//~| SUGGESTION .await
|
||||
Ok(_) => {}
|
||||
//~^ ERROR mismatched types [E0308]
|
||||
Err(_) => {}
|
||||
//~^ ERROR mismatched types [E0308]
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -106,6 +106,42 @@ help: consider `await`ing on the `Future`
|
|||
LL | let _x = match dummy().await {
|
||||
| ++++++
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-missing-await.rs:67:9
|
||||
|
|
||||
LL | Ok(_) => {}
|
||||
| ^^^^^ expected opaque type, found enum `Result`
|
||||
|
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/suggest-missing-await.rs:57:28
|
||||
|
|
||||
LL | async fn dummy_result() -> Result<(), ()> {
|
||||
| ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type
|
||||
= note: expected opaque type `impl Future`
|
||||
found enum `Result<_, _>`
|
||||
help: consider `await`ing on the `Future`
|
||||
|
|
||||
LL | match dummy_result().await {
|
||||
| ++++++
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/suggest-missing-await.rs:69:9
|
||||
|
|
||||
LL | Err(_) => {}
|
||||
| ^^^^^^ expected opaque type, found enum `Result`
|
||||
|
|
||||
note: while checking the return type of the `async fn`
|
||||
--> $DIR/suggest-missing-await.rs:57:28
|
||||
|
|
||||
LL | async fn dummy_result() -> Result<(), ()> {
|
||||
| ^^^^^^^^^^^^^^ checked the `Output` of this `async fn`, expected opaque type
|
||||
= note: expected opaque type `impl Future`
|
||||
found enum `Result<_, _>`
|
||||
help: consider `await`ing on the `Future`
|
||||
|
|
||||
LL | match dummy_result().await {
|
||||
| ++++++
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue