-
Notifications
You must be signed in to change notification settings - Fork 933
Open
Labels
bugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.
Description
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).
Metadata
Metadata
Assignees
Labels
bugPanic, non-idempotency, invalid code, etc.Panic, non-idempotency, invalid code, etc.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
ytmimi commentedon Jan 6, 2025
Yes, the output should be idempotent. Thanks for reporting this!
ytmimi commentedon Jan 6, 2025
Related to #6116, but I'm not sure if this is a duplicate.
mu001999 commentedon Jan 9, 2025
I tested and this can be fixed by #6128, so this is a duplicate
ytmimi commentedon Jan 23, 2025
From what I can tell, #6128 doesn't resolve this, though the fix might be something similar.
Formatting the input produces:
And formatting the snippet above outputs: