rust-lang / rust-lang/rust-clippy
`missing-docs-allow-unused` doesn't catch associated `const`s.
@Kokoro2336 is already working on this.
Since May 24, 2026.
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
Summary
I suggested missing-docs-allow-unused in #14413 which has been useful, but it seems it was a bit constrained in its scope and only applies to fields. However I ran into the case today where the missing-docs-allow-unused behaved unexpectedly - it didn't silence an error in a const _SIZE_TEST: () = { assert!(...) } declaration where I'd have expected it to.
Could it be expanded to include any declaration that has an identifier that is _-prefixed?
Lint Name
missing_docs_in_private_items
Reproducer
I tried this code:
//! Test
pub struct Foo(pub usize);
impl Foo {
const _SIZE_ASSERT: () = {
assert!(
core::mem::size_of::<Self>().is_multiple_of(4),
"not a multiple of 4"
);
};
}
# clippy.toml
missing-docs-allow-unused = true
I saw this happen:
error: missing documentation for an associated constant
--> src/lib.rs:5:5
|
5 | / const _SIZE_ASSERT: () = {
6 | | assert!(
7 | | core::mem::size_of::<Self>().is_multiple_of(4),
8 | | "not a multiple of 4"
9 | | );
10 | | };
| |______^
I expected no clippy lint to emit.
Version
clippy 0.1.90 (1159e78c47 2025-09-14)
Additional Labels
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.