Indentation of commented code
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
My editor has a feature to comment-out code by adding // at the beginning of the line (I expect most have something similar). When rustfmt sees this, it just adds indentation and warns if the line gets too long.
Usually when this happens it's because some code is temporarily disabled for testing. Would it be too much to ask if rustfmt would not indent comments starting at the beginning of the line but just warn about it?
"Comment at the beginning of the line" is really just a proxy identifier for commented-out-code; unfortunately I can't think of a better one since identifying code is non-trivial and in any case comments can contain code.
Example:
fn main() {
let mut x = 1;
// x += 5;
println!("x: {}", x);
}
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
The issue names no source file or test; start by reproducing the provided Rust snippet with rustfmt and trace how comment indentation is handled. Done means comments beginning at column zero remain there, while overly long lines still produce the requested warning, with the behavior covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100