Skip to content

Commit 9edce86

Browse files
authored
Rollup merge of rust-lang#145735 - joshtriplett:style-guide-trailing-whitespace, r=joshtriplett
style-guide: Document absence of trailing whitespace We didn't previously have a blanket prohibition on trailing whitespace. Adding one, inspired by discussion in rust-lang#145617 .
2 parents 90f5101 + df324fa commit 9edce86

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/doc/style-guide/src/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ fn bar() {}
112112
fn baz() {}
113113
```
114114

115+
### Trailing whitespace
116+
117+
Do not include trailing whitespace on the end of any line. This includes blank
118+
lines, comment lines, code lines, and string literals.
119+
120+
Note that avoiding trailing whitespace in string literals requires care to
121+
preserve the value of the literal.
122+
115123
### Sorting
116124

117125
In various cases, the default Rust style specifies to sort things. If not
@@ -225,8 +233,8 @@ newline after the opening sigil, and a newline before the closing sigil.
225233

226234
Prefer to put a comment on its own line. Where a comment follows code, put a
227235
single space before it. Where a block comment appears inline, use surrounding
228-
whitespace as if it were an identifier or keyword. Do not include trailing
229-
whitespace after a comment or at the end of any line in a multi-line comment.
236+
whitespace as if it were an identifier or keyword.
237+
230238
Examples:
231239

232240
```rust

0 commit comments

Comments
 (0)