rust-lang / rust-lang/rustfmt

Use of incorrect width when rewriting nested doc comment can lead to doc comment exceeding the max width

Open
#5,531 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

My config:

unstable_features = true
error_on_line_overflow = true
error_on_unformatted = true
format_code_in_doc_comments = true
format_strings = true
hex_literal_case = "Lower"
imports_granularity = "Crate"
normalize_comments = true
reorder_impl_items = true
reorder_imports = true
group_imports = "StdExternalCrate"
reorder_modules = true
use_field_init_shorthand = true
wrap_comments = true

Version: rustfmt 1.5.1-nightly (84f0c3f7 2022-09-03)

Hard to explain with text so here's a recording:
https://user-images.githubusercontent.com/82576556/188334072-8fb46dd0-e76c-46ce-8f03-8db6a08eb096.mov

It even "fixes" the string being split with \

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 nested doc-comment formatting issue with the configuration shown in the report and compare the result with the attached recording. Trace the formatter path responsible for rewriting nested doc comments and verify that the output respects the configured maximum width without splitting the string incorrectly. Done means the reported case formats without exceeding the maximum width or introducing the incorrect split.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.