Closed
Description
A common problem when using async-await is to forget to invoke .await
. This often shows up as a type error, e.g. in a case like this (playground):
#![feature(async_await)]
async fn make_u32() -> u32 {
22
}
fn take_u32(x: u32) {
}
async fn foo() {
let x = make_u32();
take_u32(x);
}
fn main() { }
currently we give a rather generic error:
error[E0308]: mismatched types
--> src/main.rs:13:14
|
13 | take_u32(x);
| ^ expected u32, found opaque type
|
= note: expected type `u32`
found type `impl std::future::Future`
it'd be nice if we could suggest adding .await
somewhere.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done
Activity
nikomatsakis commentedon May 23, 2019
cc @rust-lang/wg-diagnostics @estebank
nikomatsakis commentedon May 23, 2019
@wycats was reporting a much worse error, but I'm quite sure what he did to encounter it:
Probably has something to do with streams?
estebank commentedon May 23, 2019
This will be harder to do for chained expessions
future.field_or_resolved_future.execute_new_future()?
that should have beenfuture.await.field_or_resolved_future.execute_new_future().await?
.cramertj commentedon May 23, 2019
@nikomatsakis Looks like @wycats's error was the same, it's just that the output type of the future is more complicated (
Pin<Box<Stream<Item = Value> + Send + 'static>>
).cofibrant commentedon Jun 17, 2019
Hi, I'd be really interested in working on this
davidtwco commentedon Jun 17, 2019
@doctorn awesome! Sending
@rustbot claim
should assign you to the issue and feel free to start a topic in the #wg-async-foundations stream if you need a hand.cofibrant commentedon Jun 17, 2019
@rustbot claim
.await
keyword #62067Rollup merge of rust-lang#62067 - doctorn:await_diagnostic, r=matthew…
Rollup merge of rust-lang#62067 - doctorn:await_diagnostic, r=matthew…
31 remaining items