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

Clean up E0752 explanation #75482

Merged
merged 3 commits into from
Aug 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/librustc_error_codes/error_codes/E0752.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
`fn main()` or the specified start function is not allowed to be
async. You might be seeing this error because your async runtime
library is not set up correctly.
The entry point of the program was marked as `async`.

Erroneous code example:

```compile_fail,E0752
async fn main() -> Result<i32, ()> {
async fn main() -> Result<i32, ()> { // error!
Ok(1)
}
```

`fn main()` or the specified start function is not allowed to be `async`. You
might be seeing this error because your async runtime library is not set up
correctly. To fix it, don't declare the entry point as `async`:
GuillaumeGomez marked this conversation as resolved.
Show resolved Hide resolved

```
fn main() -> Result<i32, ()> { // ok!
Ok(1)
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should put up 3rd party suggestions in case a beginner stumbled up upon this, for example #[tokio::runtime].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We mention it, but I'm not sure it's a good idea to bring a specific library into a "general" example.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did we mentioned it? I don't quite like bringing a specific library here too but I believe beginners might not understand what is an async runtime, I first heard of the concept async runtime when I use rust so I do think we should point them somewhere. I don't have a good idea how but that is my suggestion.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this point, the error itself is clear enough. Imagine having an error with smol and seeing this explanation talk about tokio, it would be more confusing than helpful for newcomers I think.