Following the advice of doc_include_without_cfg
causes missing_docs
to trigger instead #13918
Open
Description
opened on Jan 1, 2025
Summary
The crate I'm working on had this for its crate documentation:
#![doc = include_str!("../README.md")]
I came across the doc_include_without_cfg
lint and thought it made sense, so I turned it on and followed its suggestion, changing the above to
#![cfg_attr(doc, doc = include_str!("../README.md"))]
but now, the missing_docs
lint triggers instead:
warning: missing documentation for the crate
--> src\lib.rs:1:1
|
1 | / #![cfg_attr(doc, doc = include_str!("../README.md"))]
2 | | //
3 | | // only enables the `doc_cfg` feature when
4 | | // the `docsrs` configuration attribute is defined
... |
|
= note: requested on the command line with `-W missing-docs`
Lint Name
doc_include_without_cfg
Reproducer
I tried this code:
#![cfg_attr(doc, doc = include_str!("../README.md"))]
I saw this happen:
warning: missing documentation for the crate
I expected to see this happen:
I expected clippy
to be smart enough to understand its own suggested lint fix and realize that the crate does, in fact, have documentation due to the doc = include_str!
.
Version
rustc 1.85.0-nightly (4d669fb34 2024-12-08)
binary: rustc
commit-hash: 4d669fb34e7db6f3825d01e4c59b7996f0531431
commit-date: 2024-12-08
host: x86_64-pc-windows-msvc
release: 1.85.0-nightly
LLVM version: 19.1.5
Additional Labels
No response
Activity