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

Option to skip uneccessary match arm brackets #5351

Closed
TheBlueMatt opened this issue May 24, 2022 · 1 comment
Closed

Option to skip uneccessary match arm brackets #5351

TheBlueMatt opened this issue May 24, 2022 · 1 comment
Labels
a-matches match arms, patterns, blocks, etc duplicate

Comments

@TheBlueMatt
Copy link

If rustfmt decides to indent after the => in a match (because the line ran too long) it also adds a {} and an extra line (for the }) even if the contents of the match arm fit onto a single line.

In the example at rust-bitcoin/rust-bitcoin#959 (comment) rustfmt generated

Error::SerializationError => {
    "can not serialize the spending transaction in Transaction::verify()"
},

when it arguably could have (optionally) just stuck with

Error::SerializationError =>
    "can not serialize the spending transaction in Transaction::verify()",

unlike ifs (and the C world) you can't get screwed by the lack of {} here - if you end up with two statements back-to-back its a compile error rather than incorrect logic.

Thanks!

@calebcartwright
Copy link
Member

Thanks for sharing, but going to close as a duplicate of #4896

You may want to also subscribe to #4924. It may have stalled out a bit but made good progress and is the most likely candidate for implementation

@calebcartwright calebcartwright closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2022
@ytmimi ytmimi added duplicate a-matches match arms, patterns, blocks, etc labels May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-matches match arms, patterns, blocks, etc duplicate
Projects
None yet
Development

No branches or pull requests

3 participants