-
Notifications
You must be signed in to change notification settings - Fork 924
Add config option to control leading match arm pipes #4090
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
Add config option to control leading match arm pipes #4090
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should support the following three variants for this config option:
- Always remove the leading
|
(this should be the default) - Always add the leading
|
- Keep the presence or the absence of the leading
|
(this corresponds tostrip_leading_match_arm_pipes == false
)
I think that the second variant is essential for those who want to have the leading pipe consistently throughout their codebase. What do you think?
Yeah that sounds reasonable 👍 Perhaps something like the below?
|
24b5ae8
to
6d87061
Compare
Yeah, that seems reasonable to me! |
6d87061
to
1239d71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @calebcartwright Are you planning to add any updates to this PR? If not, feel free to merge by yourself at any point.
Thanks a lot, this is awesome. :) |
Glad to hear it @RalfJung!
I suspect that match formatting configurability will definitely be an area of review and consideration for us once we get rustfmt 2.0 shipped (which will include this option), especially since there's quite a few match-related bugs and feature requests open. As usual the defaults for any such future config option(s) would need to adhere to the style guide but I do think there's some opportunities to give users some opt-in control/flexibility via config options. We'll certainly consider the benefit/possibility of |
I'm eager to try this out. :) What would it take to get this into a nightly? Can I just submit a PR bumping the submodule in rustc or are there things to be aware of? |
We should be ready to update the submod in rustc with a 2.0 release candidate within the next week or two, but we're not quite ready just yet. The only way to try it out at the moment would be building rustfmt from master. |
Oh I didn't know there was a major release coming, I'll wait then. :) |
I am now using rustfmt in the latest rust nightly
but this option still does not seem to be available? For testing, I added this to my config
but there is no effect. On the terminal I can even see
|
Oh, looks like rust nightly is not tracking rustfmt master. |
That's correct. master is rustfmt 2.0 which has one more issue left (#2908) that we need to get sorted before 2.0 is ready for nightly I was actually thinking about this one the other day and wondering if folks think |
|
backported in #4436 |
Resolves #3973 (at least the leading pipe, not the
=>
on its own line)