rust-lang / rust-lang/rustfmt

`normalize_comments = true` causes malformed comments

Open
#4,971 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-comments only-with-option
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Input:

struct A {
    x: usize,
    /* protected int[] observed; */
    /* (int, int)[] stack; */
}

Expected output:

struct A {
    x: usize,
    /* protected int[] observed;
     * (int, int)[] stack; */
}

or

struct A {
    x: usize,
    // protected int[] observed;
    // (int, int)[] stack;
}

Actual output:

struct A {
    x: usize,
    /* protected int[] observed; */
     * (int, int)[] stack; */
}

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 example with rustfmt using normalize_comments = true, then trace the comment-normalization entry point responsible for adjacent block comments. The fix is done when the input produces one valid block comment or separate line comments without duplicated delimiters, with a regression test covering this case.

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
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.