rust-lang / rust-lang/rustfmt

Feature Request: Vertical semicolon when wrapping function chains

Open
#5,451 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request community driven P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

I ended up writing this feature request formatted like the Rustfmt options docs. Please let me know if more information is needed or if I somehow missed that this option already exists.

fn_chain_vertical_semicolon

Vertically wrap the semicolon at the end of a vertical function chain.

Pros
  • Easier to visually scan the leftmost character to see when the method calls stop and the semicolon ends the statement.
  • IDEs that support single-line commenting don't have to be corrected after commenting out the last line.
    • e.g. in the false example, an IDE may replace .dolor(); with // .dolor(); and comment out the semicolon causing an error.
Cons
  • Adds a basically empty line, making code taller than necessary.

  • Default: I don't know how this is decided. As it is currently unimplemented, the default is false.
  • Possible Values: true, false

false:

fn main() {
    lorem
        .ipsum()
        .dolor();
}

true:

fn main() {
    lorem
        .ipsum()
        .dolor()
        ;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No implementation files or tests are named. Start by locating rustfmt's handling of vertically wrapped function chains and its option-definition and documentation paths, then compare the current and requested examples. Done means the option is defined, documented, applied to the chain layout, and covered by formatter tests for both values.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.