Skip to content

"Expected type, found {x}" message could be more helpful #41928

Closed
@wesleywiser

Description

@wesleywiser

I mistyped a ; as a : because it was following a ) which requires holding the shift key on American keyboards. It would be nice if the error message mentioned why it was expecting a type.

Sample code:

fn main() {
    println!("test"):
    0;
}

Current error:

rustc 1.17.0 (56124baa9 2017-04-24)
error: expected type, found `0`
 --> <anon>:3:5
  |
3 |     0;
  |     ^

error: aborting due to previous error

It would be nice if it said something like this:

rustc 1.17.0 (56124baa9 2017-04-24)
error: expected type, found `0`
 --> <anon>:3:5
  |
3 |     0;
  |     ^

error: aborting due to previous error

--> <anon>:2:21
  |
2 |   println!("test"):
  |                   ^

hint: expecting a type because of type ascription here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions