Open
Description
This seems related to #42424, except I don't see an obvious workaround like in #42424.
#![feature(async_await)]
use std::io::Error;
fn make_unit() -> Result<(), Error> {
Ok(())
}
fn main() {
let fut = async {
make_unit()?;
Ok(())
};
}
Fails with the error
error[E0282]: type annotations needed for `impl std::future::Future`
--> src/main.rs:11:9
|
10 | let fut = async {
| --- consider giving `fut` the explicit type `impl std::future::Future`, with the type parameters specified
11 | make_unit()?;
| ^^^^^^^^^^^^ cannot infer type
First of all, it seems like this shouldn't be an error--it should be able to deduce that the return type is Result<(), io::Error>
, but also the diagnostic does not work. If you try to add impl std::future::Future<Output=Result<(), Error>>
as a type annotation, it also fails to compile because impl Trait
is only allowed as return types and argument types.
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitArea: Messages for errors, warnings, and lintsArea: Type inferenceArea: Suggestions generated by the compiler applied by `cargo fix`Async-await issues that have been triaged during a working group meeting.Diagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.Relevant to the compiler team, which will review and decide on the PR/issue.