Skip to content

[Book]: Add new section for collections of lints, that focus on the same problem #11808

Open
@tigerros

Description

@tigerros

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 Results or Options 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
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-documentationArea: Adding or improving documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions