From db2a989565ea2b3d3c06e34cd385cfb574a32fbb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 13 Apr 2021 12:20:54 +0300 Subject: internal: don't use `#[should_panic]` for tests --- docs/dev/style.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docs/dev/style.md') 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. **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 -- cgit v1.2.3