Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Following the advice of doc_include_without_cfg causes missing_docs to trigger instead #13918

Open
ilyvion opened this issue Jan 1, 2025 · 0 comments
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@ilyvion
Copy link

ilyvion commented 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

@ilyvion ilyvion added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

No branches or pull requests

1 participant