diff options
author | Aleksey Kladov <[email protected]> | 2020-08-02 13:59:18 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-08-02 13:59:18 +0100 |
commit | e96bfd812a0f883bc9aa6b5ebe3b0a712c860487 (patch) | |
tree | 6a0b7c79e66046c6cfbda130bda5fe91a9fa5dd2 | |
parent | edee52fa577ad3143777644d9b5e764b4e0a837d (diff) |
Tweak style wording
-rw-r--r-- | docs/dev/style.md | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index 0a85b4a55..1c68f5702 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -67,7 +67,8 @@ as long as they are still readable. | |||
67 | 67 | ||
68 | ## Order of Imports | 68 | ## Order of Imports |
69 | 69 | ||
70 | We separate import groups with blank lines | 70 | Separate import groups with blank lines. |
71 | Use one `use` per crate. | ||
71 | 72 | ||
72 | ```rust | 73 | ```rust |
73 | mod x; | 74 | mod x; |
@@ -92,7 +93,7 @@ Order them in "suggested reading order" for a person new to the code base. | |||
92 | 93 | ||
93 | ## Import Style | 94 | ## Import Style |
94 | 95 | ||
95 | Items from `hir` and `ast` should be used qualified: | 96 | Qualify items from `hir` and `ast`. |
96 | 97 | ||
97 | ```rust | 98 | ```rust |
98 | // Good | 99 | // Good |
@@ -144,7 +145,7 @@ struct Foo { | |||
144 | 145 | ||
145 | ## Variable Naming | 146 | ## Variable Naming |
146 | 147 | ||
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)). |
148 | The default name is a lowercased name of the type: `global_state: GlobalState`. | 149 | The default name is a lowercased name of the type: `global_state: GlobalState`. |
149 | Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`). | 150 | Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`). |
150 | The default name for "result of the function" local variable is `res`. | 151 | The default name for "result of the function" local variable is `res`. |
@@ -152,12 +153,12 @@ The default name for "I don't really care about the name" variable is `it`. | |||
152 | 153 | ||
153 | ## Collection types | 154 | ## Collection types |
154 | 155 | ||
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`. |
156 | They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount. | 157 | They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount. |
157 | 158 | ||
158 | ## Preconditions | 159 | ## Preconditions |
159 | 160 | ||
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): |
161 | 162 | ||
162 | ```rust | 163 | ```rust |
163 | // Good | 164 | // Good |
@@ -205,7 +206,7 @@ If the line is too long, you want to split the sentence in two :-) | |||
205 | 206 | ||
206 | We don't have specific rules around git history hygiene. | 207 | We don't have specific rules around git history hygiene. |
207 | Maintaining clean git history is encouraged, but not enforced. | 208 | 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. |
209 | 210 | ||
210 | Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors). | 211 | Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors). |
211 | Such messages create a lot of duplicate notification traffic during rebases. | 212 | Such messages create a lot of duplicate notification traffic during rebases. |