-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Code (Playground)
use futures::{future::ready, join};
async fn _incorrect_error() {
join! { ready(0) };
// Produces cannot infer type for `{integer}` for expression above
0.await;
}
fn main() {}
produces following errors:
Errors
error[E0277]: the trait bound `{integer}: core::future::future::Future` is not satisfied
--> src/main.rs:6:5
|
6 | 0.await;
| ^^^^^^^ the trait `core::future::future::Future` is not implemented for `{integer}`
|
= help: the following implementations were found:
<&mut F as core::future::future::Future>
<futures_channel::oneshot::Receiver<T> as core::future::future::Future>
<futures_task::future_obj::FutureObj<'_, T> as core::future::future::Future>
<futures_task::future_obj::LocalFutureObj<'_, T> as core::future::future::Future>
and 84 others
error[E0698]: type inside `async fn` body must be known in this context
--> src/main.rs:4:5
|
4 | join! { ready(0) };
| ^^^^^^^^^^^^^^^^^^^ cannot infer type for `{integer}`
|
note: the type is part of the `async fn` body because of this `await`
--> src/main.rs:4:5
|
4 | join! { ready(0) };
| ^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0698]: type inside `async fn` body must be known in this context
--> src/main.rs:4:5
|
4 | join! { ready(0) };
| ^^^^^^^^^^^^^^^^^^^ cannot infer type for `{integer}`
|
note: the type is part of the `async fn` body because of this `await`
--> src/main.rs:4:5
|
4 | join! { ready(0) };
| ^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0698]: type inside `async fn` body must be known in this context
--> src/main.rs:4:5
|
4 | join! { ready(0) };
| ^^^^^^^^^^^^^^^^^^^ cannot infer type for `{integer}`
|
note: the type is part of the `async fn` body because of this `await`
--> src/main.rs:4:5
|
4 | join! { ready(0) };
| ^^^^^^^^^^^^^^^^^^^
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0698]: type inside `async fn` body must be known in this context
--> src/main.rs:6:5
|
6 | 0.await;
| ^ cannot infer type for `{integer}`
|
note: the type is part of the `async fn` body because of this `await`
--> src/main.rs:6:5
|
6 | 0.await;
| ^^^^^^^
error[E0698]: type inside `async fn` body must be known in this context
--> src/main.rs:6:5
|
6 | 0.await;
| ^^^^^^^ cannot infer type for `{integer}`
|
note: the type is part of the `async fn` body because of this `await`
--> src/main.rs:6:5
|
6 | 0.await;
| ^^^^^^^
However, if we remove line
0.await;
, it will become valid. Error on this line affects unrelated
join! { ready(0) };
and produces cannot infer type for {integer}
error for valid expression. This behaviour could seem not so bad, but imagine large async
function with many lines (you can simply copy-paste first line several times and look to the output).
sanket143
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-inferenceArea: Type inferenceArea: Type inferenceAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.