CFG Attribute with deny(missing_docs) not working


#1

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: https://play.rust-lang.org/?gist=e866ac700d2fb51ecbeda3ac36a1fbb6&version=stable&mode=debug&edition=2015
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.


#2

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


#3

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?


#4

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.)


#5

This appears pretty relevant:


#6

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.