Skip to content

provide better diagnostic for forgotten semicolon token #32540

Closed
@bungcip

Description

@bungcip

this code

fn main(){
    let value = 20;
    let m = match value {
        20 => true,
        40 => false,
        _ => false
    }

    println!("{}", m);
}

give this error message:

C:\depot>rustc ex.rs
ex.rs:9:5: 9:12 error: expected one of `.`, `;`, `?`, or an operator, found `println`
ex.rs:9     println!("{}", m);
            ^~~~~~~
error: aborting due to previous error

ideally, the error is something like this:

C:\depot>rustc ex.rs
ex.rs:7:5: 7:12 error: expected one of `.`, `;`, `?`, or an operator after '}' token
ex.rs:7     }
            ^~
error: aborting due to previous error

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions