Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustfmt requires two runs to converge on contrived input #6437

Open
jrose-signal opened this issue Jan 6, 2025 · 3 comments
Open

rustfmt requires two runs to converge on contrived input #6437

jrose-signal opened this issue Jan 6, 2025 · 3 comments
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@jrose-signal
Copy link

jrose-signal commented Jan 6, 2025

fn test(input: Foo) {
    match input {
        Foo::Bar => {
            ;
            Baz {
                field: 0
            }
        }
    }
}

Given this admittedly contrived input, running rustfmt once removes the semicolon. Running it a second time removes the braces for the match body.

I don't know if rustfmt has a rule about being idempotent, but it certainly would surprise me to regularly encounter situations where I have to manually run it to a fixed point.

Tested in the playground, 1.8.0-stable (2024-11-26 90b35a6239).

@ytmimi
Copy link
Contributor

ytmimi commented Jan 6, 2025

Yes, the output should be idempotent. Thanks for reporting this!

@ytmimi
Copy link
Contributor

ytmimi commented Jan 6, 2025

Related to #6116, but I'm not sure if this is a duplicate.

@ytmimi ytmimi added the bug Panic, non-idempotency, invalid code, etc. label Jan 6, 2025
@mu001999
Copy link
Contributor

mu001999 commented Jan 9, 2025

I tested and this can be fixed by #6128, so this is a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

3 participants