Skip to content

#[expect(clippy::missing_docs_in_private_items)] causes unfulfilled_lint_expectations when building tests #16934

@emilazy

Description

@emilazy

Summary

The same as rust-lang/rust#130021; Clippy inherited this code from rustc:

if cx.tcx.sess.opts.test {
return false;
}

rustc removed it in rust-lang/rust#130025, which fixed missing_docs, but clippy::missing_docs_in_private_items has not picked that up.

(I don’t know whether this counts as a false negative or a false positive…)

Lint Name

missing_docs_in_private_items

Reproducer

I tried this code:

#![warn(clippy::missing_docs_in_private_items)]

pub fn public() {
    private();
}

#[expect(clippy::missing_docs_in_private_items)]
fn private() {}

I expected to see this happen:

shion:/v/f/1/j/T/tmp.xdpOLKV5bl/clippy-bug-reproducer
❭ cargo clippy --all-targets
    Checking clippy-bug-reproducer v0.1.0 (/private/var/folders/1v/jtp_4pzx7xq371f8j_xdnrvm0000gn/T/tmp.xdpOLKV5bl/clippy-bug-reproducer)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.10s

Instead, this happened:

shion:/v/f/1/j/T/tmp.xdpOLKV5bl/clippy-bug-reproducer
❭ cargo clippy --all-targets
    Checking clippy-bug-reproducer v0.1.0 (/private/var/folders/1v/jtp_4pzx7xq371f8j_xdnrvm0000gn/T/tmp.xdpOLKV5bl/clippy-bug-reproducer)
warning: this lint expectation is unfulfilled
 --> src/lib.rs:7:10
  |
7 | #[expect(clippy::missing_docs_in_private_items)]
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unfulfilled_lint_expectations)]` on by default

warning: `clippy-bug-reproducer` (lib test) generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.12s

Version

rustc 1.94.0 (4a4ef493e 2026-03-02) (built from a source tarball)
binary: rustc
commit-hash: 4a4ef493e3a1488c6e321570238084b38948f6db
commit-date: 2026-03-02
host: aarch64-apple-darwin
release: 1.94.0
LLVM version: 21.1.8

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions