-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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
#[tokio::main]
async fn test(){
}
#[tokio::main]
async fn main() {
test().await;
}
Current output
Compiling playground v0.0.1 (/playground)
error[E0277]: `()` is not a future
--> src/main.rs:8:12
|
8 | test().await;
| ------ ^^^^^ `()` is not a future
| |
| this call returns `()`
|
= help: the trait `Future` is not implemented for `()`
= note: () must be a future or must implement `IntoFuture` to be awaited
= note: required for `()` to implement `IntoFuture`
help: remove the `.await`
|
8 - test().await;
8 + test();
|
help: alternatively, consider making `fn test` asynchronous
|
2 | async async fn test(){
| +++++
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` (bin "playground") due to 1 previous error
Desired output
The error report should point to the fact that #[tokio::main] should not be added before the first function.
Rationale and extra context
No response
Other cases
Rust Version
rustc 1.88.0 (6b00bc388 2025-06-23)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: x86_64-pc-windows-msvc
release: 1.88.0
LLVM version: 20.1.5
Anything else?
No response
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.