Skip to content

missing_errors_doc warns on test functions when check-private-items = true #13391

Closed
@GrantGryczan

Description

@GrantGryczan

Summary

When check-private-items = true is set in clippy.toml, missing_errors_doc warnings can appear on test functions, even though there's no reason to document the meanings of errors returned by test functions, since these errors won't used by other code.

Lint Name

missing_errors_doc

Reproducer

I tried this code:

#[warn(clippy::missing_errors_doc)]
#[test]
fn test() -> Result<(), ()> {
    Ok(())
}

I saw this happen:

warning: docs for function returning `Result` missing `# Errors` section
 --> src/main.rs:7:1
  |
7 | fn test() -> Result<(), ()> {
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_errors_doc
note: the lint level is defined here
 --> src/main.rs:5:8
  |
5 | #[warn(clippy::missing_errors_doc)]
  |        ^^^^^^^^^^^^^^^^^^^^^^^^^^


I expected to see this happen:

No warning.

Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-pc-windows-msvc
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions