rust-lang / rust-lang/rustfmt

Enable configuration to selectively wrap some comments and leave others unwrapped

Open
#4,752 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-comments C-feature-request P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

📋 Description

wrap_comments should have configuration to only wrap some comments and leave others untouched.

Currently the configuration feature wrap_comments will wrap both doc comments and normal comments. This is very desirable for doc comments where the purpose is for humans to read and understand the text. It's also very desirable for comments which aren't meant for documentation but instead describe the code for readers of the source.

Unfortunately, it's painful for another very common use of comments: disabling small sections of code temporarily. In particular, a large section of code which is at times near the column width will get re-wrapped as text if it's commented out and then reformatted. This can make it more challenging to temporarily disable a section of code.

It'd be nice to have an affordance for non-wrapped comments as well as wrapped comments. For instance, // comments could be unwrapped while /// and /* */ comments could be wrapped. The workflow here is best when the "unwrapped" comment is the same as whatever the user's editor applies to highlighted sections of text (which, for me using IntelliJ is //).

Other notes

  • Depending on the implementation, there may be an interaction with normalize_comments.

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 tracing the wrap_comments configuration and its interaction with normalize_comments; the issue does not name files or tests. Define the configuration behavior for wrapped and unwrapped comment forms, including the documented examples, and verify that each category is formatted as intended.

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
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.