rust-lang / rust-lang/rustfmt

Long statements continues on its own line

Open
#3,626 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-call-chains I-poor-formatting
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Playground

I tried to format this code:

fn main() {
    let visual_studio_path = {
        let vswhere_stdout = String::from_utf8(vswhere_output.stdout)
    .expect("vswhere output is not valid UTF-8");
        String::from(vswhere_stdout.trim())
    };
}

What I expect:

fn main() {
    let visual_studio_path = {
        let vswhere_stdout = String::from_utf8(vswhere_output.stdout)
            .expect("vswhere output is not valid UTF-8");
        String::from(vswhere_stdout.trim())
    };
}

What I got:

fn main() {
    let visual_studio_path = {
        let vswhere_stdout =
            String::from_utf8(vswhere_output.stdout).expect("vswhere output is not valid UTF-8");
        String::from(vswhere_stdout.trim())
    };
}

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

Start with the linked Rust Playground reproduction and compare rustfmt's output with the expected formatting for the chained call. Trace the formatter behavior responsible for placing the long statement continuation on its own line; done means the reproduction matches the expected indentation without regressing related formatting.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.