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

Suggestion: warn if no await inside async fn or block #4629

Closed
neoeinstein opened this issue Oct 4, 2019 · 5 comments
Closed

Suggestion: warn if no await inside async fn or block #4629

neoeinstein opened this issue Oct 4, 2019 · 5 comments
Labels
A-lint Area: New lints L-correctness Lint: Belongs in the correctness lint group T-async-await Type: Issues related to async/await

Comments

@neoeinstein
Copy link

neoeinstein commented Oct 4, 2019

In general, if you aren't awaiting anything, then there is no reason to have an async fn or async {…}. Using async where it is not needed can lead to unnecessary overhead. This lint would alert users to cases where they may have started off writing something as async, but then refactored, removing all await points without deleting the async keyword.

@tesuji
Copy link
Contributor

tesuji commented Oct 5, 2019

Does rustc lint about this? I think it is better to be linted by rustc.

@flip1995 flip1995 added L-correctness Lint: Belongs in the correctness lint group A-lint Area: New lints T-async-await Type: Issues related to async/await labels Oct 5, 2019
@neoeinstein
Copy link
Author

I was a bit surprised that rustc wasn't complaining about this, but figured I'd post here first. I can make a similar suggestion to the Rust project, and continue this issue only if it is rejected there.

@DevinR528
Copy link
Contributor

Somewhat related, could we also lint if a future is not awaited inside of async context. I kept forgetting to add the .await and since its not an error it silently breaks the program.

@loyd
Copy link

loyd commented Mar 23, 2022

#7176

@giraffate
Copy link
Contributor

I'm closing this because the unused_async has been implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints L-correctness Lint: Belongs in the correctness lint group T-async-await Type: Issues related to async/await
Projects
None yet
Development

No branches or pull requests

6 participants