rust-lang / rust-lang/rustfmt

rustfmt fails to format array that contains more than one struct lit which exceeds max_width

Open
#4,403 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-strings I-poor-formatting P-medium
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Describe the bug

I have a const array of structs. If the array has more than 8 elements rustfmt will not format the file.

To Reproduce

Run rstfmt on the contents of https://gist.github.com/farrel/c982304bdefe5c2ee2c8ee8207a3e0ff

Expected behavior

The file should be formatted.

Meta

  • rustfmt version: rustfmt 1.4.17-stable (8a93416 2020-07-20)
  • From where did you install rustfmt?: rustup
  • How do you run rustfmt: rustfmt, cargo-fmt, vim integration (all fail)

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 failure with rustfmt on the linked gist, including an array with more than eight struct literals and elements exceeding max_width. Trace the array formatting path and verify the result through rustfmt, cargo-fmt, and the reported Vim integration; done means the input formats successfully and the regression is covered.

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.