rust-lang / rust-lang/rustfmt

perpetually increasing indentation

Open
#6,161 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

trying to format the following code increases the indentation by one level on some of it, every time rustfmt is run, it increases the indentation another level. by running rustfmt repeatedly, I was able to produce line widths of more than 1000.

https://play.rust-lang.org/?version=stable&mode=release&edition=2021&gist=8c150c886832e90a4543a2d3a794d4a6

macro_rules! my_macro {
    ($($tt:tt)*) => {};
}

fn f() {
    my_macro! {
        m =>
        "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa": r"bbbbbbbbbbbbbbbbbbbbbb
                        cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
",
    };
}

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 by reproducing the linked playground example with rustfmt, running the formatter repeatedly on the provided macro invocation and raw string. Trace the formatting path for this input; done means repeated runs produce identical indentation and line widths no longer grow.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.