rustfmt insists on making comment lines too long for lists containing URLs

Aperta
#7,262 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
63/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
tooling

Direzione di ricerca

The comment-rewrapping logic lives in src/comment.rs in the rustfmt source; start by grepping there for wrap_comments and comment_width to find where a line is split into words. Reproduce with the echo ... | rustfmt +nightly --config wrap_comments=true,max_width=40,comment_width=40 command in the report, then check whether URL tokens are treated as unbreakable and whether the list-item indent is reapplied after the URL. Done means both examples keep the line under comment_width and a regression test under tests/ covers the idempotent case.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

A-markdown C-bug UO-comment_width UO-wrap_comments

When a Markdown list within a comment contains a too-long line that also contains a URL, rustfmt won't wrap it:

> rustfmt +nightly --version
rustfmt 1.12.0-nightly (bdf712ee87 2026-11-21)

> echo '// * Lorem ipsum dolor sit amet http://google.com' | rustfmt +nightly --config wrap_comments=true,max_width=40,comment_width=40
// * Lorem ipsum dolor sit amet http://google.com

Worse, when you wrap it manually to fix the long line, rustfmt will undo your work and make it too long again:

> echo '// * Lorem ipsum dolor sit amet
//   http://google.com' | rustfmt +nightly --config wrap_comments=true,max_width=40,comment_width=40
// * Lorem ipsum dolor sit amet http://google.com
Lingua principale
Rust
Stelle
7.1k
Fork
1.2k
Merge medio
1g 4h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-lang/rustfmt

Tutte le issue di rust-lang/rustfmt

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.