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

Invalid suggestion when attempting to call async closure #62386

Closed
Aaron1011 opened this issue Jul 4, 2019 · 2 comments
Closed

Invalid suggestion when attempting to call async closure #62386

Aaron1011 opened this issue Jul 4, 2019 · 2 comments
Labels
A-async-await Area: Async & Await A-closures Area: closures (`|args| { .. }`) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-async_closure `#![feature(async_closure)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Aaron1011
Copy link
Member

Aaron1011 commented Jul 4, 2019

The following snippet:

#![feature(async_await)]

fn main() {
    async || ({
    })();
}

produces the following error:

error[E0618]: expected function, found `()`
 --> src/main.rs:4:14
  |
4 |        async || ({
  |   ______________^
  |  |______________|
  | ||
5 | ||     })();
  | ||______^_- call expression requires function
  | |_______|
  | 
help: if you meant to create this closure and immediately call it, surround the closure with parenthesis
  |
4 |     async || (({
5 |     }))();
  |

However, applying this suggestion doesn't actually fix the error. Instead, it simply causes a new suggestion to be produced - this time with three parentheses (e.g. ((() instead of two.

@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 4, 2019
@Centril Centril added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Jul 5, 2019
@Centril
Copy link
Contributor

Centril commented Jul 5, 2019

Labeling as deferred since async closures are not getting stabilized in the MVP.

@Centril Centril added F-async_await F-async_closure `#![feature(async_closure)]` A-closures Area: closures (`|args| { .. }`) requires-nightly This issue requires a nightly compiler in some way. and removed F-async_await labels Jul 28, 2019
@estebank estebank added the D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. label Oct 5, 2019
@compiler-errors
Copy link
Member

This is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-closures Area: closures (`|args| { .. }`) A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. C-bug Category: This is a bug. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. F-async_closure `#![feature(async_closure)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants