rust-lang / rust-lang/rustfmt

rustfmt removes newlines in comments between chain calls

Open
#4,012 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-call-chains A-comments A-whitespace P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Unsure if this is intentional, but I assume it isn't. rustfmt removes newlines in comments between chain calls. I can get behind removing newlines between line comments, but removing them in block comments I find odd.

Original Code:

Minimal example to reproduce issue.

let x = (0..3)
        /*
        Foo

        Bar
        */
        .map(|i| i + 1)
        // Foo

        // Bar
        .map(|i| i + 1)
        /*
        Foo


        Bar
        */
        .collect::<Vec<_>>();

Formatted Code:

let x = (0..3)
        /*
        Foo
        Bar
        */
        .map(|i| i + 1)
        // Foo
        // Bar
        .map(|i| i + 1)
        /*
        Foo
        Bar
        */
        .collect::<Vec<_>>();

rustfmt 1.4.9-stable (33e36670 2019-10-07)

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

Reproduce the issue with the minimal Rust example in the report using rustfmt 1.4.9-stable. Compare the original and formatted output, then trace the comment-formatting path for comments between chained calls. Done should preserve blank lines in block comments while confirming the existing line-comment behavior.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.