Formatting config option: `force_explicit_return`
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
Línea de trabajo
Start by locating the existing force_explicit_abi configuration option and the formatter entry points for function bodies and branches. Done means the new option consistently adds explicit return statements for the shown value-returning and unit-returning examples, with coverage for branching cases.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Feature Request
Summary
I'd like the option to force all branches of all functions to use the optional return keyword.
Motivation
I think explicitly stating return rather than relying on the implicit behavior of {} blocks makes code easier to understand at a glance, and especially if there are complicated branching statements inside. (Admittedly, this is mostly a style preference, so I understand that it probably won't be a high-priority change.)
For a toy example, the proposed formatting option should change this:
fn add_one(x: u32) -> u32 {
x + 1
}
fn foo() -> () {
println!("This function has no return value!");
}
to this:
fn add_one(x: u32) -> u32 {
return x + 1;
}
fn foo() -> () {
println!("This function has no return value!");
return;
}
This syntax is more familiar to developers with backgrounds in other languages, such as C/C++, and follows the common Rust pattern that explicit is better than implicit.
Related configuration options
I wasn't able to find anything that was directly related to my proposed option, but it would follow in the spirit of options like force_explicit_abi.
- Lenguaje dominante
- Rust
- Estrellas
- 7.1k
- Forks
- 1.2k
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 20
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de rust-lang/rustfmt
-
A-config C-bug SO-print-config
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día
-
A-Unicode C-bug P-low
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
rust-lang/rustfmt#7210 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
A-imports C-bug E-hard I-non-idempotency X-impacts-stable-default-format
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
rust-lang/rustfmt#7173 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
A-comments C-bug only-with-option UO-indent_style
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Fix `first_line_width` to be tab-awareQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. AbiertoA-tabs A-whitespace C-bug SO-hard_tabs
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
Todos los issues de rust-lang/rustfmt
Issues similares
-
bug P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
bug core-lang
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Windows microphone listing treats words in a device name as DirectShow labelsPosiblemente ocupada @Sujal-chaudhary la tomó hoy. Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
clipy-recorder/clipy#447 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
nightly-cleanup
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
max-sixty/worktrunk#4939 · 1 reacción ·
Los mantenedores suelen responder en 1 día