diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-13 09:23:24 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-13 09:23:24 +0000 |
| commit | 11e7371df7b7ba7f47ae4892eb8b0f98b371de70 (patch) | |
| tree | 27d88010e9441d2af973f04c9b979220b0b07ebf /docs/dev | |
| parent | 6081b437cc842f8885c26636bef8af4cbc5483e3 (diff) | |
| parent | db2a989565ea2b3d3c06e34cd385cfb574a32fbb (diff) | |
| download | rust-11e7371df7b7ba7f47ae4892eb8b0f98b371de70.tar.gz rust-11e7371df7b7ba7f47ae4892eb8b0f98b371de70.zip | |
Merge #8499
8499: internal: don't use `#[should_panic]` for tests r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
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 468dedff20d..7c47c26b2d4 100644 --- a/docs/dev/style.md +++ b/docs/dev/style.md @@ -152,6 +152,16 @@ Do not reuse marks between several tests. **Rationale:** marks provide an easy way to find the canonical test for each bit of code. This makes it much easier to understand. +More than one mark per test / code branch doesn't add significantly to understanding. + +## `#[should_panic]` + +Do not use `#[should_panic]` tests. +Instead, explicitly check for `None`, `Err`, etc. + +**Rationale:**a `#[should_panic]` is a tool for library authors, to makes sure that API does not fail silently, when misused. +`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. +Panic messages in the logs from the `#[should_panic]` tests are confusing. ## Function Preconditions |
