rust-lang / rust-lang/rustfmt

Non-idempotency in consecutive block comment

Open
#7,019 1 comment 0 reactions 1 assignee View on GitHub

@saberoueslati is already working on this.

Since Aug 10, 2026.

A-comments C-bug I-non-idempotency
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Summary

Reported in https://github.com/rust-lang/rustfmt/issues/6639#issuecomment-5235145262 by @yuxqiu, split out to its own issue.

I tried to format this code:

fn f() -> usize {
    /*A*/ /*B*/
    1 + 2
}
Expected behavior

I expected to see this happen: be idempotent.

Actual behavior

Instead, this happened: formatting is non-idempotent and takes 2 steps to converge:

start

fn f() -> usize {
    /*A*/ /*B*/
    1 + 2
}

start -> form 1

fn f() -> usize {
    /*A*/
 /*B*/
    1 + 2
}

form 1 -> form 2

fn f() -> usize {
    /*A*/
    /*B*/
    1 + 2
}

Configuration

rustfmt cli options used (if applicable):

$ rustfmt +stable --config-path=/dev/null

rustfmt configuration file (e.g. rustfmt.toml, if applicable): none

Reproduction Steps

$ cat foo.rs
fn f() -> usize {
    /*A*/ /*B*/
    1 + 2
}

$ rustfmt +stable --config-path=/dev/null foo.rs # step 1
$ cat foo.rs
fn f() -> usize {
    /*A*/
 /*B*/
    1 + 2
}

$ rustfmt +stable --config-path=/dev/null foo.rs # step 2
$ cat foo.rs
fn f() -> usize {
    /*A*/
    /*B*/
    1 + 2
}

Meta

rustfmt --version:

rustfmt 1.9.0-stable (8bab26f4f6 2026-07-14)

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.