rust-lang / rust-lang/rust-clippy

Separate `check-private-items` configuration for different lints

Open
#13,074 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

Issue

check-private-items currently controls behavior of multiple lints, e.g. missing_panics_doc and missing_safety_doc.

However, I would like to check even private items for safety docs but I don't care as much about panics. Especially since we also lint tests where I often use panics.

Proposal

Add more fine-grained options which can override check-private-items:

  • check-private-items-missing-panics-doc
  • check-private-items-missing-safety-doc
  • ... possibly more

Then clippy.toml such as

check-private-items = false
check-private-items-missing-safety-doc = true

would work like this:

#![warn(missing_panics_doc)]
#![warn(missing_safety_doc)]

// This would be warned against because of `missing_safety_doc`
unsafe fn private_unsafe_fun() {}

// This would be warned against because of `missing_panics_doc`
pub fn public_panicking_fun() { panic!(); }

// This would not be warned against because it's a panic inside a private function
fn private_panicking_fun() { panic!(); }

Version

No response

Additional Labels

@rustbot label +C-enhancement

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 tracing how check-private-items is handled for the missing_panics_doc and missing_safety_doc lints. Determine how per-lint configuration should override the shared option, then verify that the proposed settings distinguish private safety documentation from private panic documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.