rustfmt gives legal length comments a ragged edge in argument lists

Abierto
#7,167 8 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@matthewhughes934 ya está trabajando en esto.

Desde el 9/10/2026.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
65/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 reported output with the nested Rust argument-list example and the shown rustfmt configuration (wrap_comments = true, comment_width = 100). Read rustfmt's comment-wrapping implementation and its tests for comments in argument lists; the issue does not name specific files. Done means formatting preserves the reported legal-length comment without producing the ragged reflow shown.

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

Descripción

A-comments C-bug UO-comment_width UO-wrap_comments

Here is a Rust file with no line longer than 100 bytes, and one line equal to 100 bytes:

fn main() {
    if true {
        if true {
            if true {
                if true {
                    if true {
                        if true {
                            foo(
                                // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
                                // eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
                                // enim ad minim veniam, quis nostrud exercitation ullamco laboris
                                // nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
                                // reprehenderit in voluptate velit esse cillum dolore eu fugiat
                                // nulla pariatur.
                                1,
                            );
                        }
                    }
                }
            }
        }
    }
}

The comment shouldn't be changed by rustfmt, but it does change it, giving it a very ragged edge:

> cat config.toml
wrap_comments = true
comment_width = 100

> rustfmt +nightly --version
rustfmt 1.11.0-nightly (1d81eb4ad9 2026-10-07)

> rustfmt +nightly --emit=stdout --config-path config.toml foo.rs
fn main() {
    if true {
        if true {
            if true {
                if true {
                    if true {
                        if true {
                            foo(
                                // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
                                // eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
                                // enim ad minim veniam, quis nostrud exercitation ullamco laboris
                                // nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
                                // in reprehenderit in voluptate
                                // velit esse cillum dolore eu fugiat
                                // nulla pariatur.
                                1,
                            );
                        }
                    }
                }
            }
        }
    }
}
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.