Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad error message with async main #68523

Open
Nokel81 opened this issue Jan 24, 2020 · 11 comments
Open

Bad error message with async main #68523

Nokel81 opened this issue Jan 24, 2020 · 11 comments

Comments

@Nokel81
Copy link
Contributor

@Nokel81 Nokel81 commented Jan 24, 2020

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.

@Centril

This comment has been minimized.

Copy link
Member

@Centril Centril commented Jan 28, 2020

Implementation notes:

cc @estebank who has dealt with fn main diagnostics recently.

@estebank

This comment has been minimized.

Copy link
Contributor

@estebank estebank commented Jan 28, 2020

This is a good first-contribution ticket I can help with.

@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 Nokel81 commented Jan 28, 2020

I will take you up on that offer Wednesday evening if that is good with you.

@Centril

This comment has been minimized.

Copy link
Member

@Centril Centril commented Jan 28, 2020

@rustbot rustbot self-assigned this Jan 28, 2020
@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 Nokel81 commented Jan 30, 2020

@rustbot claim

@rustbot rustbot assigned rustbot and unassigned rustbot Jan 30, 2020
@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 Nokel81 commented Jan 30, 2020

@estebank Though I realize it might be too late for today. But how should be chat?

@estebank

This comment has been minimized.

Copy link
Contributor

@estebank estebank commented Jan 30, 2020

I'm on the street now, but if you have specific questions I can answer them when I get home.

@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 Nokel81 commented Feb 16, 2020

Work is going well. I should have a preliminary PR up early next week.

@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 Nokel81 commented Feb 18, 2020

I have two things that I have run into:

  1. should I be using rustc_span::source_map::dummy_spanned?
  2. I am having trouble figuring out why I get a bug! panic at src/librustc_metadata/rmeta/decoder.rs:398: Cannot decode Span without Session., would anyone have an idea as to how to set up a Session?
@estebank

This comment has been minimized.

Copy link
Contributor

@estebank estebank commented Feb 18, 2020

@Nokel81 could you push your code to a branch we can look at and comment inline? You should be extracting an existing span.

@Nokel81

This comment has been minimized.

Copy link
Contributor Author

@Nokel81 Nokel81 commented Feb 19, 2020

  1. There is a bunch of places in the code where map_or_else or a default hir::IsAsync::NotAsync was used and I needed to a way to make it Spanned<hir::IsAsync>
  2. https://github.com/Nokel81/rust/tree/async_main_error
  3. I am also having trouble trying to figure out where fn main is type checked as different then any other function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.