From 3715fc623a8464d27601309693b826063564bfcd Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 21 Aug 2025 18:34:59 -0700 Subject: [PATCH 1/2] style-guide: Document absence of trailing whitespace --- src/doc/style-guide/src/README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/doc/style-guide/src/README.md b/src/doc/style-guide/src/README.md index f42b9cb597843..a20f62d65a59d 100644 --- a/src/doc/style-guide/src/README.md +++ b/src/doc/style-guide/src/README.md @@ -112,6 +112,11 @@ fn bar() {} fn baz() {} ``` +### Trailing whitespace + +Do not include trailing whitespace on the end of any line. This includes blank +lines, comment lines, and code lines. + ### Sorting In various cases, the default Rust style specifies to sort things. If not @@ -225,8 +230,8 @@ newline after the opening sigil, and a newline before the closing sigil. Prefer to put a comment on its own line. Where a comment follows code, put a single space before it. Where a block comment appears inline, use surrounding -whitespace as if it were an identifier or keyword. Do not include trailing -whitespace after a comment or at the end of any line in a multi-line comment. +whitespace as if it were an identifier or keyword. + Examples: ```rust From df324fa7c8f96ed064f90c7b24c31d605eedc9b8 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Wed, 3 Sep 2025 01:56:53 -0700 Subject: [PATCH 2/2] Add note about trailing whitespace in string literals. --- src/doc/style-guide/src/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/doc/style-guide/src/README.md b/src/doc/style-guide/src/README.md index a20f62d65a59d..c3788c97ae69a 100644 --- a/src/doc/style-guide/src/README.md +++ b/src/doc/style-guide/src/README.md @@ -115,7 +115,10 @@ fn baz() {} ### Trailing whitespace Do not include trailing whitespace on the end of any line. This includes blank -lines, comment lines, and code lines. +lines, comment lines, code lines, and string literals. + +Note that avoiding trailing whitespace in string literals requires care to +preserve the value of the literal. ### Sorting