Skip to content

trailing_semicolon = false changes the meaning of code, non-idempotent #5797

@digama0

Description

@digama0

The trailing_semicolon = false option, when run on this code:

fn foo() {}
fn main() {
    return;
    foo()
}

turns it into

fn foo() {}
fn main() {
    return
    foo()
}

which now runs foo() where it did not before, as a second run of rustfmt will make clearer:

fn foo() {}
fn main() {
    return foo()
}

Observed on rustfmt 1.5.3-nightly (065a1f5 2023-06-21).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: this is a bug; use also I-* labels for specific bug kinds, e.g. I-non-idempotency or I-ICE

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions