rustfmt removes trailing line after Markdown list in doc comments

Aperta
#7,274 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
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
rust
Ambito
tooling

Direzione di ricerca

Start by reproducing the issue with the provided Rust example and rustfmt +nightly --config wrap_comments=true, then locate the comment-formatting logic that distinguishes doc comments from regular comments. Check the formatter’s existing comment and doc-comment tests. The work is done when the selected behavior is consistent and the example is covered by a regression test.

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

Descrizione

C-bug needs-triage

When a doc comment ends with a markdown list, rustfmt won't let it end with a blank line, which I'd like to do for visual separation. However, it is inconsistent about this: it applies to doc comments, but not regular comments.

Input:

/// A function that fits three criteria:
///
/// * Does A really well.
/// * Does B okay, I guess.
/// * Does C not very well at all.
///
pub fn foo() {
    // Three notes about the implementation we need:
    //
    // * A
    // * B
    // * C
    //
    todo!()
}
> rustfmt +nightly --version
rustfmt 1.12.0-nightly (6181cc4f07 2026-11-28)

> cat foo.rs | rustfmt +nightly --config wrap_comments=true

In the output, the doc comment has been messed with, but not the normal comment:

/// A function that fits three criteria:
///
/// * Does A really well.
/// * Does B okay, I guess.
/// * Does C not very well at all.
pub fn foo() {
    // Three notes about the implementation we need:
    //
    // * A
    // * B
    // * C
    //
    todo!()
}

I would prefer that the doc comment be left alone, but they should at least be consistent one way or another.

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.