-
Notifications
You must be signed in to change notification settings - Fork 926
Strip leading |
in match arm patterns
#2621
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
Comments
Should we have an option for preserving/removing the leading |
I don't think we need an option here. I think we probably want to support #2234 as an option for those who want a leading |
I would be interested in fixing this if someone could provide a hint regarding which files to start looking in. |
@Mike-Baker awesome! You should look at https://github.com/rust-lang-nursery/rustfmt/blob/master/src/matches.rs in particular |
This adresses issue rust-lang#2621 This turns out to be a partial revert of ea3c01e
This adresses issue rust-lang#2621 This commit turns out to be a partial revert of ea3c01e The rationale is that a `|` character preceding a match pattern is not semantically relevant and therefore should be considered a style/formatting choice. A discussion concluded that the best way to emit consistant formatting here was to strip the leading `|` Discussion at rust-lang/style-team#119
This addresses issue rust-lang#2621 This commit turns out to be a partial revert of ea3c01e The rationale is that a `|` character preceding a match pattern is not semantically relevant and therefore should be considered a style/formatting choice. A discussion concluded that the best way to emit consistent formatting here was to strip the leading `|` Discussion at rust-lang/style-team#119
@nrc Thank you for the pointers, having a relevant starting point made it a lot easier to get to grips with rustfmt! I have something I think works (added a new test and all tests pass) here or a squashed version I based my changes off 84598bd because current master (1415a4d) is failing to build due to errors in rustc-ap-syntax I am concerned that this looks a lot like an effective revert of ea3c01e and if in future we would like to support #2234 then we would need to revert this revert, also I think I have duplicated a test which was introduced in the aforementioned commit. Questions:
|
Current master should be building now, please rebase. The branch looks good, I don't think you should worry abou reverting ea3c01e - #2234 is a bit different to that in that it would be an option to always insert a leading For the tests, I think |
@Mike-Baker Hey, did you get a chance to rebase your branch? Any more questions I can help with? |
@nrc Hi, sorry for the delay. Previous weekends I have been running into errors
(Fixed) and
(Fixed) Then
(still in effect) This is on OSX with
|
@Mike-Baker you'll need to |
@Mike-Baker did you get a chance to rebase and did that solve your problems? Anything else I can help with? |
This addresses issue rust-lang#2621 This commit turns out to be a partial revert of ea3c01e The rationale is that a `|` character preceding a match pattern is not semantically relevant and therefore should be considered a style/formatting choice. A discussion concluded that the best way to emit consistent formatting here was to strip the leading `|` This removes the match_with_beginning_vert test because it was asserting the old behaviour which has been changed, it adds a new test (issue_2621) which should be a more comprehensive check of the behavior of `|` in match arms. Discussion at rust-lang/style-team#119
@nrc Sorry for the delay, I have finally got everything building again so I have rebased and got the tests in line. Here are the changes since last time. Here is the pull request |
Minor notes: It seems that things don't build on current nightly (fails with But it does build on nightly-2018-06-20. I also managed to get to a state somewhere that running |
Closed by #2804 |
See discussion in rust-lang/style-team#119. We might need to revisit this if the discussion changes direction.
The text was updated successfully, but these errors were encountered: