Open
Description
Note: The start of the issue is a discussion, how to best address the suggestion. This comment outlines what should be done. The rest can be used for context.
What it does
restriction
-level lint that checks for code that might panic. For example, right now there's unwrap_used
, or expect_used
. This would unify those types of lints. Ideally, it would also be able to detect other sources of panics, like calling a function that might panic. I noticed that missing_panics_doc
is not triggered when a user-defined function that panics is called, which is a problem.
Advantage
Panicking is generally discouraged, and handling errors with Result
s or Option
s is recommended.
Drawbacks
It can be overly restrictive, and likely wouldn't provide a fix in certain cases.
Example
let numbers = &[4, 7, 3];
let my_number = numbers[5];
Could be written as:
let numbers = &[4, 7, 3];
let Some(my_number) = numbers.get(5) else {
// handle
};