diff options
author | Aleksey Kladov <[email protected]> | 2021-01-22 14:58:00 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-01-22 14:58:00 +0000 |
commit | e54a398bfbe864223e20e8a1f526b434e1c89164 (patch) | |
tree | 91f63047083eee3a6373eb63befd0981407df115 | |
parent | 71fe719dd5247ed8615641d9303d7ca1aa201c2f (diff) |
Promote marks
-rw-r--r-- | docs/dev/style.md | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index 7e6cd49e0..428cee3ad 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): |
@@ -380,13 +391,12 @@ Compile time **does not** obey this rule -- all code has to be compiled. | |||
380 | 391 | ||
381 | ## Appropriate String Types | 392 | ## Appropriate String Types |
382 | 393 | ||
383 | When interfacing with OS APIs, use `OsString`, even if the original source of | 394 | 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 | 395 | **Rationale:** cleanly delineates the boundary when the data goes into the OS-land. |
385 | data goes into the OS-land. | ||
386 | 396 | ||
387 | Use `AbsPathBuf` and `AbsPath` over `std::Path`. **Rationale:** rust-analyzer is | 397 | Use `AbsPathBuf` and `AbsPath` over `std::Path`. |
388 | a long-lived process which handles several projects at the same time. It is | 398 | **Rationale:** rust-analyzer is a long-lived process which handles several projects at the same time. |
389 | important not to leak cwd by accident. | 399 | It is important not to leak cwd by accident. |
390 | 400 | ||
391 | # Premature Pessimization | 401 | # Premature Pessimization |
392 | 402 | ||