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

Missing docs lint ineffectual in test builds #24584

Open
fenhl opened this issue Apr 19, 2015 · 3 comments
Open

Missing docs lint ineffectual in test builds #24584

fenhl opened this issue Apr 19, 2015 · 3 comments
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.

Comments

@fenhl
Copy link
Contributor

fenhl commented Apr 19, 2015

The missing_docs lint does not do anything in test builds. Minimal code example:

#![cfg_attr(test, deny(missing_docs))]

To reproduce, make a new crate, replace src/lib.rs with the above code, and run cargo test. The command will run successfully. I would expect the command to report a “missing documentation for crate” compile error.

As for the cause, my wild guess is some sort of interaction between cfg(test) and which items are detected as public.

@sfackler sfackler added the A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. label Apr 19, 2015
@steveklabnik
Copy link
Member

Triage: as a slightly more full example, this crate will compile with --test, but not compile without it:

#![deny(missing_docs)]

#[test]
fn foo() {}

fn lol() {}

fn main() {}

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
@steveklabnik
Copy link
Member

Triage: no change

@ehuss
Copy link
Contributor

ehuss commented Sep 26, 2020

This is also an issue for editors that use cargo check --profile=test in order to include tests in the check. This means the lint doesn't ever fire in the editor.

It looks like the check was added in 4a5d887. I suspect the reasoning is that code inside a cfg(test) block should not be checked for missing docs, which makes sense. I think it would be nicer to allow missing_docs to run with --test, but to not check any block/module/item that is marked with cfg(test). Unfortunately, I think that is very difficult or impossible to do. 😦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: Lints (warnings about flaws in source code) such as unused_mut. C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants