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 selections in function arguments does not agree with RFC 166 #207

Open
oxalica opened this issue Jun 23, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@oxalica
Copy link

oxalica commented Jun 23, 2024

Description

Related: #153

I'm trying to apply RFC 166 style on rust-overlay and noticed this weird formatting.

Small example input

{
  rust-channel-of-version = assertEq (rustChannelOf { channel = "1.48.0"; }).rustc stable."1.48.0".rustc;
}

Expected output

{
  rust-channel-of-version = assertEq (rustChannelOf { channel = "1.48.0"; }).rustc
    stable."1.48.0".rustc;
}

Actual output

{
  rust-channel-of-version = assertEq (rustChannelOf { channel = "1.48.0"; })
    .rustc stable."1.48.0".rustc;
}

It splits the selection in the first argument, but does not put the second arguments on a newline, which is really confusing to me. It looks like (assertEq (..)).rustc instead of assertEq ((..).rustc)

Rationale

As described in RFC 166:

Function application

  • In a function application chain, the first element is treated as the "function" and the remaining ones as "arguments".
  • As many arguments as possible must be fit onto the first line.
  • If there is at most one multi-line argument that can be absorbed and all other arguments before/after fit onto a single line respectively, then that multi-line argument is absorbed.

Thus the first argument should be inlined as a whole, and the second argument should be put on a new line (otherwise it would exceed the max width 100).

@dasJ dasJ added the bug Something isn't working label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants