Skip to content

style: Never break within a nullary function call func() or a unit literal () #140764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/doc/style-guide/src/editions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/doc/style-guide/src/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading