Skip to content

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

Closed
@luser

Description

@luser

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions