rust-lang / rust-lang/rust-clippy

False negatives for missing_docs_in_private_items since 1.79.

Open
#14,301 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

Apparently there are circumstances where missing_docs_in_private_items fails to report errors; they seem to have strange, non-local behavior.

Lint Name

missing_docs_in_private_items

Reproducer

I ran cargo clippy --all-features with Rust 1.85 using this code as my lib.rs.

//! Documented.

#![deny(clippy::missing_docs_in_private_items)]

/// Documented.
#[derive(Debug)]
#[allow(dead_code)]
struct Mine {
    //// Note use of four /s.  No warning here.
    undocumented_1: String,
}

#[derive(serde::Deserialize)]
pub(crate) struct Undocumented2 {}

Here's the Cargo.toml I used:

[package]
name = "clippy-repro"
version = "0.1.0"
edition = "2021"

[features]
f = []

[dependencies]
serde = { version = "1.0.218", features = ["derive"] }

I expected to see warnings from undocumented_1 and Undocumented2.

Instead, no warnings were produced.

I tried removing #[derive(Debug)] from Mine: It caused a warning to start appearing on Undocumented2!

I tried with older versions of Clippy: Rust version 1.78 and earlier correctly give warnings; Rust 1.79 is the first version that fails to warn at all.

Version
rustc 1.85.0 (4d91de4e4 2025-02-17)
binary: rustc
commit-hash: 4d91de4e48198da2e33413efdcd9cd2cc0c46688
commit-date: 2025-02-17
host: x86_64-unknown-linux-gnu
release: 1.85.0
LLVM version: 19.1.7

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 with the supplied lib.rs and Cargo.toml reproducer, running Clippy with Rust 1.78 and 1.79 or later to isolate the regression. Investigate the missing_docs_in_private_items lint behavior around the derive attributes; done means warnings are reported for both undocumented_1 and Undocumented2 without depending on unrelated derives.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.