rust-lang / rust-lang/rustfmt

wrap_comments wraps too early

Open
#5,890 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-comments only-with-option UO-wrap_comments
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

I have a very simple example where using wrap_comments lead to the doc line being wrapped even if it is exactly 80 characters.

/**
 * A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A
 */
fn main() {}

I played around with comment_width and it wrapped this line even with comment_width = 83 but stopped wrapping with 84 so somehow the wrapping is off by 4 here.

Also interesting if I do the same with 100 characters and comment_width = 100 it also wraps and if I increase the comment_width it still wraps always, regardless how high I set comment_width.

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 reproducing the supplied Rust snippet with wrap_comments and several comment_width values, including the 80-, 83-, 84-, and 100-character cases. Trace the comment-wrapping entry point and add a regression test covering the boundary and persistent-wrapping behavior. Done means comment lines wrap at the configured width without the reported four-character offset.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.