Skip to content

Commit e96bfd8

Browse files
committed
Tweak style wording
1 parent edee52f commit e96bfd8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/dev/style.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ as long as they are still readable.
6767

6868
## Order of Imports
6969

70-
We separate import groups with blank lines
70+
Separate import groups with blank lines.
71+
Use one `use` per crate.
7172

7273
```rust
7374
mod x;
@@ -92,7 +93,7 @@ Order them in "suggested reading order" for a person new to the code base.
9293

9394
## Import Style
9495

95-
Items from `hir` and `ast` should be used qualified:
96+
Qualify items from `hir` and `ast`.
9697

9798
```rust
9899
// Good
@@ -144,20 +145,20 @@ struct Foo {
144145

145146
## Variable Naming
146147

147-
We generally use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
148+
Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
148149
The default name is a lowercased name of the type: `global_state: GlobalState`.
149150
Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`).
150151
The default name for "result of the function" local variable is `res`.
151152
The default name for "I don't really care about the name" variable is `it`.
152153

153154
## Collection types
154155

155-
We prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`.
156+
Prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`.
156157
They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount.
157158

158159
## Preconditions
159160

160-
Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee):
161+
Express function preconditions in types and force the caller to provide them (rather than checking in callee):
161162

162163
```rust
163164
// Good
@@ -205,7 +206,7 @@ If the line is too long, you want to split the sentence in two :-)
205206

206207
We don't have specific rules around git history hygiene.
207208
Maintaining clean git history is encouraged, but not enforced.
208-
We use rebase workflow, it's OK to rewrite history during PR review process.
209+
Use rebase workflow, it's OK to rewrite history during PR review process.
209210

210211
Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors).
211212
Such messages create a lot of duplicate notification traffic during rebases.

0 commit comments

Comments
 (0)