-
Notifications
You must be signed in to change notification settings - Fork 395
fmt: set force_multiline_blocks=true #1850
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
Conversation
}, | ||
// Left has at least 1 element > than the implicit 0, | ||
// so the only valid values are Ordering::Greater or None. | ||
Ordering::Greater => match order { |
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.
FWIW, this kind of "having code on the same line as the =>
is actually fine IMO... having a nested match
is very difefrent from a big method call here, in my view. Oh well, I still view this diff as a net positive.^^
I don't like anything in this diff, but I also don't care much. So, fine by me |
So you're okay with code like this? _ => show_error(format!(
"`cargo-miri` called without first argument; please only invoke this binary through `cargo miri`"
)), I think this is quite bad, spreading the method call over multiple lines but sharing the first line with the pattern makes this code very hard to read IMO. |
I'm perfectly fine with it. Even outside of match arms, doing it for regular function call statements is fine by me. We do it for struct, array and tuple constructors. function calls are not special to me. |
I may just have gotten used to it. it may be hard to read, but not to me |
I am specifically talking about match arms. This quickly leads to code like Long(Pattern, That { is, not_entirely: trivial }) => something.foo().call(
a,
b
) where (in particular in the context of a large But I guess one can get used to this... |
to me |
FWIW we already have something like that in the codebase: Lines 489 to 490 in b061307
I'd much prefer if all those
We can if we also set |
That CI failure is interesting... I ran formatting on the entire codebase before psuhing. Is it possible that rustfmt is non-idempotent? |
I see... I am warming up to this PR (before the last commit). Let's go with it |
To be clear, I don't want to force this, I can also live with the status quo (though I think I'd prefer applying both commits over keeping the status quo -- and prefer just the first commit over that). |
No I really mean it. It was just very surprising at first, but I don't have any argument against it. |
All right, thanks! Landing just the first commit then. @bors r+ |
📌 Commit cffa1d3 has been approved by |
☀️ Test successful - checks-actions |
To be honest I'm not sure how much consideration went into how those two opts would work together. I was somewhat taken aback initially by the resultant formatting, though after looking at it for a bit realize that it's really the only possible formatting with the configuration combo since they'd otherwise be in a mutually exclusive conflict. I think this probably warrants some more documentation updates to clarify that |
This is an experiment, I am not yet sure if I like it... but it does prevent rustfmt from putting stuff after the
=>
in amatch
(unless the entire arm fits there), which IMO is a big plus. What do others think?(I also tried setting
match_arm_blocks
back to its default oftrue
, but that adds too many braces for my taste.)Btw, @calebcartwright is the interaction of
match_arm_blocks = false
andforce_multiline_blocks = true
as can be seen here expected? I think I like it, but it it is not at all what I expected from the docs which describeforce_multiline_blocks = true
as "Force multiline closure and match arm bodies to be wrapped in a block" -- but here that is not the effect it has, there are no new blocks being added.