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

Formatting of match arms with long guards is a bit awkward. #3005

Closed
emilio opened this issue Sep 9, 2018 · 4 comments
Closed

Formatting of match arms with long guards is a bit awkward. #3005

emilio opened this issue Sep 9, 2018 · 4 comments

Comments

@emilio
Copy link
Contributor

emilio commented Sep 9, 2018

             match *token {
                 Token::Dimension {
                     value, ref unit, ..
-                } if num_context.is_ok(context.parsing_mode, value) =>
+                }
+                    if num_context.is_ok(context.parsing_mode, value) =>
                 {
                     return NoCalcLength::parse_dimension(context, value, unit)
                         .map(LengthOrPercentage::Length)
                         .map_err(|()| location.new_unexpected_token_error(token.clone()))
                 },

Not sure it's expected, feel free to close if so, but I have never seen a human use that formatting :)

@emilio
Copy link
Contributor Author

emilio commented Sep 9, 2018

Also, this looks like a regression, since the same code was rustfmt'd already a while ago.

@scampi
Copy link
Contributor

scampi commented Sep 29, 2018

@emilio This indentation is expected I think as per the style guide. @nrc should the guide be revised or close the issue as a wont fix ?

@nrc
Copy link
Member

nrc commented Oct 7, 2018

I think we didn't consider the case where there is a } on it's own line in the pattern of the match arm. In that case, I think we should apply the 'combining' rules. This could be clarified in the style guide.

nrc added a commit to rust-lang/style-team that referenced this issue Oct 15, 2018
@crumblingstatue
Copy link
Contributor

I believe I'm experiencing the same issue with rust-sfml.
Diff from old to new rustfmt behavior:

diff --git a/examples/pong.rs b/examples/pong.rs
index 4bfa5ed..cf3928c 100644
--- a/examples/pong.rs
+++ b/examples/pong.rs
@@ -101,7 +103,8 @@ fn main() {
                 } => return,
                 Event::KeyPressed {
                     code: Key::Space, ..
-                } if !is_playing =>
+                }
+                    if !is_playing =>
                 {
                     // (re)start the game
                     is_playing = true;

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

No branches or pull requests

5 participants