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

"Remove this semicolon" lint for return values and closures #18595

Closed
alexcrichton opened this issue Nov 4, 2014 · 3 comments
Closed

"Remove this semicolon" lint for return values and closures #18595

alexcrichton opened this issue Nov 4, 2014 · 3 comments
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

@alexcrichton
Copy link
Member

Right now it looks like we don't handle closures when printing out the "consider removing this semicolon" help message (but we do handle functions!). It'd be kinda cool if we could handle closures as well (or maybe any block statement in general?

fn foo(_: || -> bool) {}

fn main() {
    foo(|| { true; });
}
@alexcrichton alexcrichton added the A-diagnostics Area: Messages for errors, warnings, and lints label Nov 4, 2014
@steveklabnik
Copy link
Member

Traige, updated code:

fn foo(_: Fn() -> bool) {}

fn main() {
        foo(|| { true; });
}

No change on status though.

@pmarcelll
Copy link
Contributor

It seems to be fixed, for this code:

fn foo<F: Fn() -> bool>(_: F) {}

fn main() {
        foo(|| { true; });
}

the output is:

error[E0308]: mismatched types
 --> <anon>:4:16
  |
4 |         foo(|| { true; });
  |                ^^^^^^^^^ expected bool, found ()
  |
  = note: expected type `bool`
             found type `()`
help: consider removing this semicolon:
 --> <anon>:4:22
  |
4 |         foo(|| { true; });
  |                      ^

error: aborting due to previous error

@steveklabnik steveklabnik added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 9, 2017
@Mark-Simulacrum
Copy link
Member

Closing in favor of collective issue for this general problem: #41897.

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

No branches or pull requests

4 participants