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

Suggestions in errors ignore move before closure arguments #55891

Closed
ghost opened this issue Nov 12, 2018 · 2 comments
Closed

Suggestions in errors ignore move before closure arguments #55891

ghost opened this issue Nov 12, 2018 · 2 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@ghost
Copy link

ghost commented Nov 12, 2018

Source: https://travis-ci.org/rust-lang/cargo/jobs/453802414#L938-L949

error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments
   --> src/cargo/core/compiler/job_queue.rs:412:23
    |
399 |         let doit = move || {
    |                    ------- takes 0 arguments
...
412 |                 scope.spawn(doit);
    |                       ^^^^^ expected closure that takes 1 argument
help: consider changing the closure to take and ignore the expected argument
    |
399 |         let doit = |_| {
    |                    ^^^

The suggestion is to use: let doit = |_| {
But I think it should be: let doit = move |_| {

We should probably respect other modifiers like static and async, too.

@csmoe csmoe added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 13, 2018
@csmoe
Copy link
Member

csmoe commented Nov 13, 2018

cc #52647
@estebank that's a bit strange, why the prefix is missed in suggestions?

@estebank
Copy link
Contributor

The closure span includes everything between the pipes, the pipes and any prefix modifier. In the suggestion, we replace the entire span. We should probably add a new way of obtaining closure spans to account for this, to be used in suggestions. The fix itself will be fairly small.

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue Nov 22, 2018
Suggest on closure args count mismatching with pipe span

Closes rust-lang#55891
r? @estebank
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
Projects
None yet
Development

No branches or pull requests

2 participants