mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-25 21:37:39 +00:00
internal: don't use #[should_panic] for tests
This commit is contained in:
parent
06a633ff42
commit
db2a989565
3 changed files with 22 additions and 24 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue