Wrapping long trailing comments
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 1.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 24
Description
(from https://github.com/rust-lang/rustfmt/issues/5577#issuecomment-3539743489, sorry for the off-topic comment!)
Don't align unrelated trailing comments after items or at the end of blocks
https://github.com/rust-lang/rustfmt/issues/5577#issuecomment-1315302533
I got hit by this change. There are occasions where I do want to break a trailing comment into multiple lines. Now I can't do that because rustfmt no longer align them.
If the intention is stopping unrelated comments from being aligned, is there a way for me to indicate that those comments are indeed related?
but i want make this issue more general. right now, rustfmt is not able to wrap long trailing comments:
func(); // a really long explanation of what this function does and why it does it and why it should be called here and such and such.
desired behavior with wrap_comments=true:
func(); // a really long explanation of what this function
// does and why it does it and why it should
// be called here and such and such
actual behavior: nothing happens.
before style-edition=2024, i could still manually break the comment up and rustfmt will properly align the lines. after, i am no longer able to, since rustfmt will format it as:
func(); // a really long explanation of what this function
// does and why it does it and why it should
// be called here and such and such
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 reproducing the issue with the trailing-comment example using wrap_comments=true, comparing the behavior before and after style-edition=2024. The work is done when long trailing comments wrap and manually split related trailing comments retain their indentation without aligning unrelated comments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 56/100