-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
When turning on the missing_docs_in_private_items lint, items that exist within a function get caught for not having documentation comments, even though adding doc comments there would not emit any documentation anyways. I've seen that this is true for inner functions and macros, and it is probably true for all items that can be declared within a function.
I feel it doesn't make too much sense to require doc comments there since I don't think there is a way to even view them via cargo doc.
Lint Name
missing_docs_in_private_items
Reproducer
I tried this code:
//! Crate-level docs.
#![warn(clippy::missing_docs_in_private_items)]
/// Example docs.
pub fn example() {
// Normal comments should be sufficient as doc comments won't get emitted anyways?
fn private_fn() -> i32 {
2 + 2
}
assert_eq!(private_fn(), 4);
println!("Hello, world!");
}I saw this happen:
❯ cargo clippy
warning: missing documentation for a function
--> src/lib.rs:8:5
|
8 | / fn private_fn() -> i32 {
9 | | 2 + 2
10 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_docs_in_private_items
note: the lint level is defined here
--> src/lib.rs:3:9
|
3 | #![warn(clippy::missing_docs_in_private_items)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I expected to see no clippy warning.
Version
rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: x86_64-unknown-linux-gnu
release: 1.83.0
LLVM version: 19.1.1
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have