From 38e3fa61f634e37ca99f7d91b770d38886c9e813 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 7 May 2025 20:31:47 +0100 Subject: [PATCH] style: Never break within a nullary function call `func()` or a unit literal `()` --- src/doc/style-guide/src/editions.md | 4 ++++ src/doc/style-guide/src/expressions.md | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/doc/style-guide/src/editions.md b/src/doc/style-guide/src/editions.md index 19e62c4867c99..81b7ff50052a9 100644 --- a/src/doc/style-guide/src/editions.md +++ b/src/doc/style-guide/src/editions.md @@ -26,6 +26,10 @@ edition). Not all Rust editions have corresponding changes to the Rust style. For instance, Rust 2015, Rust 2018, and Rust 2021 all use the same style edition. +## Rust next style edition + +- Never break within a nullary function call `func()` or a unit literal `()`. + ## Rust 2024 style edition This style guide describes the Rust 2024 style edition. The Rust 2024 style diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index 031e59d86e1da..9df5d7d18edb5 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -183,6 +183,10 @@ let f = Foo { }; ``` +## Unit literals + +Never break between the opening and closing parentheses of the `()` unit literal. + ## Tuple literals Use a single-line form where possible. Do not put spaces between the opening @@ -377,6 +381,11 @@ Do put a space between an argument, and the comma which precedes it. Prefer not to break a line in the callee expression. +For a function call with no arguments (a nullary function call like `func()`), +never break within the parentheses, and never put a space between the +parentheses. Always write a nullary function call as a single-line call, never +a multi-line call. + ### Single-line calls Do not put a space between the function name and open paren, between the open