diff options
author | Aleksey Kladov <[email protected]> | 2021-04-13 10:20:54 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2021-04-13 10:21:59 +0100 |
commit | db2a989565ea2b3d3c06e34cd385cfb574a32fbb (patch) | |
tree | 27d88010e9441d2af973f04c9b979220b0b07ebf /docs/dev | |
parent | 06a633ff421b764428bb946ced914e59532fe13f (diff) |
internal: don't use `#[should_panic]` for tests
Diffstat (limited to 'docs/dev')
-rw-r--r-- | docs/dev/style.md | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/dev/style.md b/docs/dev/style.md index 468dedff2..7c47c26b2 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md | |||
@@ -152,6 +152,16 @@ Do not reuse marks between several tests. | |||
152 | 152 | ||
153 | **Rationale:** marks provide an easy way to find the canonical test for each bit of code. | 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. | 154 | This makes it much easier to understand. |
155 | More than one mark per test / code branch doesn't add significantly to understanding. | ||
156 | |||
157 | ## `#[should_panic]` | ||
158 | |||
159 | Do not use `#[should_panic]` tests. | ||
160 | Instead, explicitly check for `None`, `Err`, etc. | ||
161 | |||
162 | **Rationale:**a `#[should_panic]` is a tool for library authors, to makes sure that API does not fail silently, when misused. | ||
163 | `rust-analyzer` is not a library, we don't need to test for API misuse, and we have to handle any user input without panics. | ||
164 | Panic messages in the logs from the `#[should_panic]` tests are confusing. | ||
155 | 165 | ||
156 | ## Function Preconditions | 166 | ## Function Preconditions |
157 | 167 | ||