Comment single-line to multi-line formatting is botched
Open
Nobody has claimed this yet.
A-comments
C-bug
I-poor-formatting
only-with-option
UO-wrap_comments
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
Given source like this:
fn foo(x: impl Iterator<Item = &'a PathBuf>) -> io::Result<impl Iterator<Item = &'a PathBuf>> {
for foo in bar {
for line in BufReader::new(File::open(banana)?)
// A fairly long comment with https://google.github.io/flatbuffers/flatbuffers_grammar.html
// an URL
.lines()
{
let peach = match (loop {}) {
Some(idx) => idx + open_quote, // get the absolute position from the original string
None => loop {},
};
}
}
}
rustfmt will produce the following diff:
.lines()
{
let peach = match (loop {}) {
- Some(idx) => idx + open_quote, // get the absolute position from the original string
+ Some(idx) => idx + open_quote, /* get the absolute position from the original
+ * string */
None => loop {},
};
}
In this diff an incorrectly aligned 2nd line of the block comment can be seen.
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 running rustfmt on the Rust reproducer in the issue and compare the single-line comment's conversion with the shown diff. No source file or test is named; locate the comment-formatting entry point and add coverage that preserves correct alignment when the comment becomes multi-line.
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
- 42/100