Skip to content

Redundant semicolons are parsed as an empty tuple semicolon statement #63679

Open
@topecongiro

Description

@topecongiro
fn foo() {
    let _ = 3;;;;
}

Given the above example, the rustc parser used to silently drop the redundant semicolons (;;;) from the AST. However, recently the parse has changed how it treats the redundant semicolons - they are now parsed as a semicolon statement with an empty tuple:

Stmt {
    node: StmtKind::Semi(Expr {
        node: ExprKind::Tup(vec![]),
        ..
    }),
    ..
}

Found this while updating rustc-ap-syntax to 562.0.0 (which is built from the commit fc8765d) in rustfmt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.T-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