rustfmt removes trailing line after Markdown list in doc comments

Abierto
#7,274 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
70/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
7.1k
Forks
1.2k
Merge medio
1 d 4 h
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rust-lang/rustfmt

Todos los issues de rust-lang/rustfmt

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.