rust-lang / rust-lang/rustfmt

`wrap_comments` can break up code snippets

Open
#5,250 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Very related to #5244 -- not sure if this should be merged with that. Either way, a similar behavior occurs with code snippets in comments. Given the following...

/// This is a comment with some code `foo bar`.

If the comment reaches the maximum width inside the code snippet, it'll break it up like so:

/// This is a comment with some code `foo
/// bar`

I think it would be more expected for it to treat the snippet as a single lexeme, and insert the line break prior to the start (foo).

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

Reproduce the reported behavior with wrap_comments enabled and a comment containing the inline code snippet foo bar near the maximum width. Trace the comment-wrapping logic and confirm that the completed behavior keeps the snippet together and moves the line break before foo; compare the related discussion in issue #5244.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.