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

Compressed chains/fn calls #4146

Open
TheBlueMatt opened this issue Apr 30, 2020 · 5 comments
Open

Compressed chains/fn calls #4146

TheBlueMatt opened this issue Apr 30, 2020 · 5 comments

Comments

@TheBlueMatt
Copy link

This may be hard to get right, but, in general, I tend to prefer putting two or three things in a fn call instead of putting each on its own line. This prevents things from getting needlessly absurdly vertical, eg this in today's rustfmt:

+                                               return_monitor_err!(
+                                                       self,
+                                                       e,
+                                                       channel_state,
+                                                       chan,
+                                                       order,
+                                                       revoke_and_ack.is_some(),
+                                                       commitment_update.is_some()
+                                               );

could be

+                                               return_monitor_err!(
+                                                       self, e, channel_state,
+                                                       chan, order,
+                                                       revoke_and_ack.is_some(),
+                                                       commitment_update.is_some()
+                                               );
@calebcartwright
Copy link
Member

Hi @TheBlueMatt

If you haven't already done so, you may want to checkout the available Configuration options (for example fn_args_layout) to see if there's anything that allows you to tune the emitted formatting to your liking.

rustfmt's default behavior is to format code according to the Rust Style Guide as defined over in https://github.com/rust-dev-tools/fmt-rfcs, though in many instances there are config options that can be used to override those defaults.

@TheBlueMatt
Copy link
Author

TheBlueMatt commented Apr 30, 2020 via email

@calebcartwright
Copy link
Member

AFAIK there's no such equivalent config option that's used for the layout of call args.

There was fn_call_style a few years ago, but that never had a Compressed variant (#2010). It was dropped since the behavior associated with a Tall variant is the default for calls and the Vertical equivalent can be achieved via the width_heuristics/fn_call_width config options.

I believe the same challenges with a Compressed-based formatting calls still exists (particularly sub expressions) so IMO we're unlikely to be able to support, though I'll defer to @topecongiro

The relevant thread in the Style Guide can be found in rust-lang/style-team#65, also a previous request for Compressed call args in #2851

@TheBlueMatt
Copy link
Author

Yea, I'd come across #2010, but its quite old at this point, and the discussion there seemed both stale (ie was at a different time in rustfmt's history) and to not actually describe why it was closed. I get that it would be hard to do Compressed in a general way, but given that it comes up from time to time, may be best to at least track it as a relatively-common feature request. Its probably a blocker for us using rustfmt given how easily rustfmt makes code really tall breaks readability as-is.

@elichai
Copy link

elichai commented Sep 9, 2020

This sounds like a nice feature!
I like rustfmt but sometimes I have big function definitions with a lot of inputs, and on one hand I don't want them on one line, but on the other, I don't want that each call will take ~11 lines

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
@TheBlueMatt @elichai @calebcartwright @topecongiro and others