CFG Attribute with deny(missing_docs) not working

Hey guys, i have a conditional deny() which i want to trigger when the user executed cargo test.
It's basically this, but doesn't work as expected: Rust Playground
Click 'Test' and notice that the compiler doesn't complain about both the module and struct not having documentation..

A non conditional deny() doesn't work either.
Am i missing something or is this an actual bug? This should be so simple that i'm just confused.

Building a crate with --test produces a binary, and the missing_docs lint does not apply to binaries.

So i'm misunderstanding then, ok.

Is this also expected behaviour when the attribute is assigned to a lib crate? https://github.com/Bert-Proesmans/cfg_test
The lib itself isn't checked at all for missing documentation?

When building with --test, the code is never checked for missing documentation.

When building without --test, library crates are checked for missing documentation if the lint is enabled. (In the linked example project, it is not.)

This appears pretty relevant:
https://github.com/rust-lang/rust/issues/24584

1 Like

Thanks for the explanation. I find this highly unintuitive though, this tool generally works except for this one specific situation.
I'm glad fixing it is being considered.