[Feature Request] Add mechanism to skip formatting specific comments
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
rustfmt usually leaves comments alone, but will edit comments when wrap_comments=true is enabled, Additionally rustfmt sometimes removes leading / trailing spaces. However, in some cases its desirable to prevent modifications for specific comments. The #[rustfmt::skip] attribute exists to prevent rustfmt from modifying annotated code, and although this will sometimes prevent comments from being modified it's not ideal because it also prevents the code from being formatted.
Related Issues where modifying comments isn't desirable:
- #5725
- #5440
- #5638
If anyone has ideas for how this mechanism could work please comment them down bellow.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing related issues #5725, #5440, and #5638, then compare the existing #[rustfmt::skip] behavior with comment formatting when wrap_comments=true. Done means a defined mechanism can preserve selected comments without also skipping formatting for their surrounding code.
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