Skip to content

Bad error message with async main #68523

Closed
@Nokel81

Description

@Nokel81

If someone tries to do the following async fn main() -> Result<(), Box<dyn std::error::Error> the error message is not helpful (though it is technically correct).

error[E0277]: `main` has invalid return type `impl futures::Future`
  --> rs/agent-updater/src/main.rs:46:20
   |
46 | async fn main() -> Result<(), Box<dyn std::error::Error>> {
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `main` can only return types that implement `std::process::Termination`
   |
   = help: consider using `()`, or a `Result`

I think that it should point to the async keyword and say that standard rust does not support async main.

This issue has been assigned to @Nokel81 via this comment.

Metadata

Metadata

Labels

A-async-awaitArea: Async & AwaitA-diagnosticsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`AsyncAwait-TriagedAsync-await issues that have been triaged during a working group meeting.C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-papercutDiagnostics: An error or lint that needs small tweaks.P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions