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

Incorrect help: suggestion for immediately called async_closures #98023

Closed
danielhenrymantilla opened this issue Jun 12, 2022 · 0 comments · Fixed by #98879
Closed

Incorrect help: suggestion for immediately called async_closures #98023

danielhenrymantilla opened this issue Jun 12, 2022 · 0 comments · Fixed by #98879
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@danielhenrymantilla
Copy link
Contributor

danielhenrymantilla commented Jun 12, 2022

Given the following code:

async || {}()

The current output is:

error[[E0618]](https://doc.rust-lang.org/nightly/error-index.html#E0618): expected function, found `()`
 --> src/main.rs:3:25
  |
3 |     let _fut = async || {}();
  |                         ^^--
  |                         |
  |                         call expression requires function
  |
help: if you meant to create this closure and immediately call it, surround the closure with parentheses
  |
3 |     let _fut = async || ({})();
  |                         +  +

Ideally the output should look like:

error[[E0618]](https://doc.rust-lang.org/nightly/error-index.html#E0618): expected function, found `()`
 --> src/main.rs:3:25
  |
3 |     let _fut = async || {}();
  |                         ^^--
  |                         |
  |                         call expression requires function
  |
help: if you meant to create this closure and immediately call it, surround the closure with parentheses
  |
3 |     let _fut = (async || {})();
  |                +           +

@rustbot modify labels +F-async_closure +requires-nightly

@danielhenrymantilla danielhenrymantilla added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2022
JohnTitor added a commit to JohnTitor/rust that referenced this issue Jul 4, 2022
…parens, r=oli-obk

Fix "wrap closure in parenthesis" suggestion for `async` closure

Fixes rust-lang#98023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this issue Jul 4, 2022
…parens, r=oli-obk

Fix "wrap closure in parenthesis" suggestion for `async` closure

Fixes rust-lang#98023
@bors bors closed this as completed in accb41e Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant