diff options
Diffstat (limited to 'docs/dev')
-rw-r--r-- | docs/dev/README.md | 6 | ||||
-rw-r--r-- | docs/dev/style.md | 29 |
2 files changed, 25 insertions, 10 deletions
diff --git a/docs/dev/README.md b/docs/dev/README.md index 24197b332..6bce38e56 100644 --- a/docs/dev/README.md +++ b/docs/dev/README.md | |||
@@ -43,6 +43,10 @@ https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0 | |||
43 | while unactionable ones are effectively wont-fix. Each triaged issue should have one of these labels. | 43 | while unactionable ones are effectively wont-fix. Each triaged issue should have one of these labels. |
44 | * [fun](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3Afun) | 44 | * [fun](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%3Afun) |
45 | is for cool, but probably hard stuff. | 45 | is for cool, but probably hard stuff. |
46 | * [Design](https://github.com/rust-analyzer/rust-analyzer/issues?q=is%3Aopen+is%3Aissue+label%Design) | ||
47 | is for moderate/large scale architecture discussion. | ||
48 | Also a kind of fun. | ||
49 | These issues should generally include a link to a Zulip discussion thread. | ||
46 | 50 | ||
47 | # CI | 51 | # CI |
48 | 52 | ||
@@ -212,7 +216,7 @@ To log all communication between the server and the client, there are two choice | |||
212 | 216 | ||
213 | * you can log on the server side, by running something like | 217 | * you can log on the server side, by running something like |
214 | ``` | 218 | ``` |
215 | env RA_LOG=gen_lsp_server=trace code . | 219 | env RA_LOG=lsp_server=debug code . |
216 | ``` | 220 | ``` |
217 | 221 | ||
218 | * you can log on the client side, by enabling `"rust-analyzer.trace.server": | 222 | * you can log on the client side, by enabling `"rust-analyzer.trace.server": |
diff --git a/docs/dev/style.md b/docs/dev/style.md index 7e6cd49e0..6dc6868c2 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -142,6 +142,17 @@ There are many benefits to this: | |||
142 | 142 | ||
143 | Formatting ensures that you can use your editor's "number of selected characters" feature to correlate offsets with test's source code. | 143 | Formatting ensures that you can use your editor's "number of selected characters" feature to correlate offsets with test's source code. |
144 | 144 | ||
145 | ## Marked Tests | ||
146 | |||
147 | Use | ||
148 | [`mark::hit! / mark::check!`](https://github.com/rust-analyzer/rust-analyzer/blob/71fe719dd5247ed8615641d9303d7ca1aa201c2f/crates/test_utils/src/mark.rs) | ||
149 | when testing specific conditions. | ||
150 | Do not place several marks into a single test or condition. | ||
151 | Do not reuse marks between several tests. | ||
152 | |||
153 | **Rationale:** marks provide an easy way to find the canonical test for each bit of code. | ||
154 | This makes it much easier to understand. | ||
155 | |||
145 | ## Function Preconditions | 156 | ## Function Preconditions |
146 | 157 | ||
147 | Express function preconditions in types and force the caller to provide them (rather than checking in callee): | 158 | Express function preconditions in types and force the caller to provide them (rather than checking in callee): |
@@ -283,8 +294,9 @@ Prefer `Default` even it has to be implemented manually. | |||
283 | 294 | ||
284 | **Rationale:** less typing in the common case, uniformity. | 295 | **Rationale:** less typing in the common case, uniformity. |
285 | 296 | ||
286 | Use `Vec::new` rather than `vec![]`. **Rationale:** uniformity, strength | 297 | Use `Vec::new` rather than `vec![]`. |
287 | reduction. | 298 | |
299 | **Rationale:** uniformity, strength reduction. | ||
288 | 300 | ||
289 | ## Functions Over Objects | 301 | ## Functions Over Objects |
290 | 302 | ||
@@ -380,13 +392,12 @@ Compile time **does not** obey this rule -- all code has to be compiled. | |||
380 | 392 | ||
381 | ## Appropriate String Types | 393 | ## Appropriate String Types |
382 | 394 | ||
383 | When interfacing with OS APIs, use `OsString`, even if the original source of | 395 | When interfacing with OS APIs, use `OsString`, even if the original source of data is utf-8 encoded. |
384 | data is utf-8 encoded. **Rationale:** cleanly delineates the boundary when the | 396 | **Rationale:** cleanly delineates the boundary when the data goes into the OS-land. |
385 | data goes into the OS-land. | ||
386 | 397 | ||
387 | Use `AbsPathBuf` and `AbsPath` over `std::Path`. **Rationale:** rust-analyzer is | 398 | Use `AbsPathBuf` and `AbsPath` over `std::Path`. |
388 | a long-lived process which handles several projects at the same time. It is | 399 | **Rationale:** rust-analyzer is a long-lived process which handles several projects at the same time. |
389 | important not to leak cwd by accident. | 400 | It is important not to leak cwd by accident. |
390 | 401 | ||
391 | # Premature Pessimization | 402 | # Premature Pessimization |
392 | 403 | ||
@@ -469,7 +480,7 @@ pub fn reachable_nodes(node: Node) -> FxHashSet<Node> { | |||
469 | } | 480 | } |
470 | ``` | 481 | ``` |
471 | 482 | ||
472 | **Rational:** re-use allocations, accumulator style is more concise for complex cases. | 483 | **Rationale:** re-use allocations, accumulator style is more concise for complex cases. |
473 | 484 | ||
474 | # Style | 485 | # Style |
475 | 486 | ||