Skip to content

Bad parse error message for missing alt close brace #2354

Closed
@catamorphism

Description

@catamorphism

In this code:

fn foo() {
  match Some(x) {
      Some(y) { fail!(); }
      None    { fail!(); }
}

fn bar() {
    let mut i = 0;
    while (i < 1000) {}
}

fn main() {}

foo is missing the close brace for the alt, but the resulting parse error message is very unhelpful:

src/test/compile-fail/bad.rs:12:13: 12:13 error: unexpected token: '<eof>'
src/test/compile-fail/bad.rs:12 fn main() {}
                                                                   ^

It would be much more helpful to report the error at the location where the un-closed brace was (in this case, after the alt in foo). I don't know how easy it would be to do with the current parser, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an AST

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions