aboutsummaryrefslogtreecommitdiff
path: root/docs/dev
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-02 13:59:18 +0100
committerAleksey Kladov <[email protected]>2020-08-02 13:59:18 +0100
commite96bfd812a0f883bc9aa6b5ebe3b0a712c860487 (patch)
tree6a0b7c79e66046c6cfbda130bda5fe91a9fa5dd2 /docs/dev
parentedee52fa577ad3143777644d9b5e764b4e0a837d (diff)
Tweak style wording
Diffstat (limited to 'docs/dev')
-rw-r--r--docs/dev/style.md13
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
70We separate import groups with blank lines 70Separate import groups with blank lines.
71Use one `use` per crate.
71 72
72```rust 73```rust
73mod x; 74mod 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
95Items from `hir` and `ast` should be used qualified: 96Qualify 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
147We generally use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)). 148Use boring and long names for local variables ([yay code completion](https://github.com/rust-analyzer/rust-analyzer/pull/4162#discussion_r417130973)).
148The default name is a lowercased name of the type: `global_state: GlobalState`. 149The default name is a lowercased name of the type: `global_state: GlobalState`.
149Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`). 150Avoid ad-hoc acronyms and contractions, but use the ones that exist consistently (`db`, `ctx`, `acc`).
150The default name for "result of the function" local variable is `res`. 151The 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
155We prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`. 156Prefer `rustc_hash::FxHashMap` and `rustc_hash::FxHashSet` instead of the ones in `std::collections`.
156They use a hasher that's slightly faster and using them consistently will reduce code size by some small amount. 157They 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
160Function preconditions should generally be expressed in types and provided by the caller (rather than checked by callee): 161Express 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
206We don't have specific rules around git history hygiene. 207We don't have specific rules around git history hygiene.
207Maintaining clean git history is encouraged, but not enforced. 208Maintaining clean git history is encouraged, but not enforced.
208We use rebase workflow, it's OK to rewrite history during PR review process. 209Use rebase workflow, it's OK to rewrite history during PR review process.
209 210
210Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors). 211Avoid @mentioning people in commit messages and pull request descriptions(they are added to commit message by bors).
211Such messages create a lot of duplicate notification traffic during rebases. 212Such messages create a lot of duplicate notification traffic during rebases.