rust-lang / rust-lang/rustfmt

Explain spans of the input file which were excluded from the formatter

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

Nobody has claimed this yet.

A-devex C-discussion
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

Often I see sections of source code which do not get reformatted, and afaics there is no way to know a) it was skipped, and b) why it was skipped.

I know of macros as a common source of this, c.f. https://github.com/rust-lang/rustfmt/issues/8 , but sometimes that doesn't explain why a section of the source code was not formatted.

I think it would be helpful if rustfmt was able to inform the user why it skipped spans of the input file while checking, or spans of the output file if reformatting. This will increase awareness in the Rust community of the current limitations of rustfmt, so they know when not to rely on it, likely also steering developers to using syntax which is compatible with rustfmt if they want to rely on rustfmt more, and possibly bringing in more contributors to rustfmt.

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 reviewing rustfmt's handling of source spans that are not reformatted, including the macro-related limitations referenced in rust-lang/rustfmt#8. Identify how skipped spans are detected during checking or reformatting and determine a user-visible way to explain both the skipped location and reason. Done means rustfmt reports excluded spans and why they were excluded.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.