rust-lang / rust-lang/rustfmt

Flickering line break

Open
#6,240 7 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

version: rustfmt 1.7.1-nightly (ba1d7f4a 2024-06-29)
config: rustfmt.toml

Formatting is flickering for looooong chain like this:

from this

let removed = roots.extract_if(|root| {  /* long block */ }).count();

to this and back:

let removed = 
    roots.extract_if(|root| {  /* long block */ }).count();

Flickering in this case means following:

  1. run rustfmt cargo/src/build/mod.rs => we've got new line-break
  2. run rustfmt cargo/src/build/mod.rs => line-break is gone
  3. repeat...

example as pr-annotation: https://github.com/boozook/playdate/pull/399#discussion_r1676418639

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 flicker with rustfmt 1.7.1-nightly using rustfmt.toml and cargo/src/build/mod.rs, repeating the documented rustfmt command. Compare the output with the examples and the PR annotation at discussion_r1676418639; done means repeated formatting produces the same line break.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.