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

Better error message than E0573 when you typo a colon in place of a semicolon #42057

Closed
luser opened this issue May 17, 2017 · 3 comments
Closed
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@luser
Copy link
Contributor

luser commented May 17, 2017

I made this typo in some code I was writing just now, a colon in place of a semicolon after a function call, with another function call on the next line:

fn f() {}

fn main() {
    f():
    f();
}

Run it on play.

The compiler errors with:

rustc 1.17.0 (56124baa9 2017-04-24)
error[E0573]: expected type, found function `f`
 --> <anon>:5:5
  |
5 |     f();
  |     ^^^ not a type

This is technically correct, but it was confusing and it took me a few minutes to realize what I had done. It would be nicer if we could guess in some circumstances that the user probably meant to put a semicolon there and say something to that effect.

@wesleywiser
Copy link
Member

Related to #41928 but not the same error message.

@luser
Copy link
Contributor Author

luser commented May 17, 2017

Oh! I looked for other issues but didn't find anything obvious. I'm happy to close this in favor of that. Could you put some of the keywords from my issue title into yours? Perhaps at least the error number, 'colon' and 'semicolon'.

@wesleywiser
Copy link
Member

I think they are separate issues since mine involves a macro. My test case doesn't actually generate an error number: playground link

@Mark-Simulacrum Mark-Simulacrum added the A-diagnostics Area: Messages for errors, warnings, and lints label Jun 23, 2017
bors added a commit that referenced this issue Jul 23, 2017
Point at `:` when using it instead of `;`

When triggering type ascription in such a way that we can infer a
statement end was intended, add a suggestion for the change. Always
point out the reason for the expectation of a type is due to type
ascription.

Fix #42057, #41928.
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

3 participants