-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Open
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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
Given the following code:
async fn my_async_fn() {}
async fn foo() {
tokio::select! {
_ = &my_async_fn() => {},
}
}
The current output is:
error[E0599]: no method named `poll` found for struct `Pin<&mut &impl Future>` in the current scope
--> src/lib.rs:5:5
|
5 | / tokio::select! {
6 | | _ = &my_async_fn() => {}
7 | | }
| |_____^ method not found in `Pin<&mut &impl Future>`
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
Given the following code:
async fn my_async_fn() {}
async fn foo() {
let fut = &my_async_fn();
tokio::pin!(fut);
fut.await;
}
The current output is:
error[E0277]: `&impl Future` is not a future
--> src/lib.rs:8:5
|
8 | fut.await;
| ^^^^^^^^^ `&impl Future` is not a future
|
= help: the trait `Future` is not implemented for `&impl Future`
= note: required because of the requirements on the impl of `Future` for `Pin<&mut &impl Future>`
= note: required by `poll`
Given the following code:
async fn my_async_fn() {}
async fn foo() {
let fut = &my_async_fn();
fut.await;
}
The current output is:
error[E0277]: `&impl Future` is not a future
--> src/lib.rs:7:5
|
7 | fut.await;
| ^^^^^^^^^ `&impl Future` is not a future
|
= help: the trait `Future` is not implemented for `&impl Future`
= note: required by `poll`
In all three cases, it would be very helpful if the compiler could explicitly call out that an immutable reference to a future is not a future. I see this relatively often in the Tokio discord where people put some extra ampersands in random places and get really confused when the error says "impl future is not future". The ampersand in the error is not enough to clue them in to what the issue is. Especially for the first case.
gamgi, EvgeniiaVak and andreisilviudragnea
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsAsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.Async-await issues that have been triaged during a working group meeting.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: Confusing error or lint; hard to understand for new users.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.E-help-wantedCall for participation: Help is requested to fix this issue.Call for participation: Help is requested to fix this issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.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.
Type
Projects
Status
Claimed