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 removes leading pipe from patterns #3973

Closed
oli-obk opened this issue Dec 21, 2019 · 6 comments · Fixed by #4090
Closed

Rustfmt removes leading pipe from patterns #3973

oli-obk opened this issue Dec 21, 2019 · 6 comments · Fixed by #4090
Milestone

Comments

@oli-obk
Copy link
Contributor

oli-obk commented Dec 21, 2019

match foo {
    | "foo"
    | "bar"
    => {}
    _ => {}
}

gets reformatted to

match foo {
    "foo"
    | "bar" => {}
    _ => {}
}

I can understand that the => on its own line needs an RFC, but the removal of the leading pipe makes that rust language feature essentially unusable.

@RalfJung
Copy link
Member

In particular, this makes it impossible to actually format a large match in "one pattern per line" style with proper alignment.

@topecongiro
Copy link
Contributor

How rustfmt should handle the leading pipe was discussed in rust-lang/style-team#119. The conclusion was to strip the leading pipe by default, but also provide an option to enable the leading pipe.

Unfortunately, we have not implemented the option yet.

@oli-obk
Copy link
Contributor Author

oli-obk commented Dec 21, 2019

@rustbot claim

@rustbot
Copy link
Collaborator

rustbot commented Dec 21, 2019

Error: This repository is not enabled to use triagebot.
Add a triagebot.toml in the root of the master branch to enable it.

Please let @rust-lang/release know if you're having trouble with this bot.

@RalfJung
Copy link
Member

Is there some issue to subscribe to so I can know when this fix is available on Rust nightly? It's been a few months but from all I could find out, this issue is still open in the latest shipped rustfmt ("rustfmt 1.4.20").

@calebcartwright
Copy link
Member

For issues like this one that have the milestone set to 2.0.0, the plan was to wait to ship them as part of the rustfmt v2.0 release which is why this isn't available in any released 1.x versions. We were originally planning to release v2.0 a long time ago, but as we started preparing to do so several questions and concerns were raised by various individuals and folks on the Dev Tools team, notably around having a major/breaking release of a tool, especially independent of something like a new Edition.

As such the 2.0 release timing, and all the features/fixes/breaking changes/etc. it contains, are in a bit of limbo at the moment. #4346 would probably be the best issue to subscribe to for updates around the 2.0 release itself.

I'm going to cut a 1.4.22 branch here shortly for the next release though, and will try to get this backported there so this will be available. In general if there's any 2.0 features/fixes/etc. that are needed more urgently then just drop us a note and we'll see if backporting to a 1.x release is viable. It's just painful and tricky for us right now as the codebase and structure between 1.x and 2.x is so different that cherrypicking is rarely possible, and we also have to rethink 2.x changes in the context of the stability guarantee that's applicable for changes that are released under a 1.x version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants