Skip to content

missing_docs triggers for integration tests #137561

Open
@tv42

Description

@tv42

Summary

If you warn on missing_docs, every integration test causes a warning from clippy --tests.

I think integration tests should be exempt from missing_docs.

My editor (https://zed.dev) (and maybe rust-analyzer by default?) shows clippy --tests messages too (and not just clippy), so having any integration tests in the tree makes missing_docs practically unusable.

Lint Name

missing_docs

Reproducer

Using the fn add example from cargo init --lib

Add to Cargo.toml

[lints.rust]
missing_docs = "warn"

add new file tests/two_plus_two.rs

use rust_clippy_missing_docs_for_tests::add;

// literally just a copy-paste from the in-library test

#[test]
fn it_works() {
    let result = add(2, 2);
    assert_eq!(result, 4);
}

And now clippy --tests complains:

$ cargo clippy --tests
warning: missing documentation for the crate
 --> tests/two_plus_two.rs:1:1
  |
1 | / use rust_clippy_missing_docs_for_tests::add;
... |
8 | |     assert_eq!(result, 4);
9 | | }
  | |_^
  |
  = note: requested on the command line with `-W missing-docs`

warning: `rust-clippy-missing-docs-for-tests` (test "two_plus_two") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s

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

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-discussionCategory: Discussion or questions that doesn't represent real issues.L-missing_docsLint: missing_docsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions