rust-lang / rust-lang/rust-clippy

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

Open
#11,808 17 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-documentation
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

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 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
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the linked issue comment, which the issue identifies as the current guidance, then inspect the Clippy Book structure to find the appropriate location for a section about collections of lints focused on the same problem. Done means the proposed collection is documented in the Book with enough context for users to understand its purpose and scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.