Add `doc(include = ...)` detection to `missing_docs_in_private_items`

This commit is contained in:
daxpedda 2019-03-14 18:32:39 +01:00
parent 729892961c
commit 177b3b27c4
No known key found for this signature in database
GPG Key ID: C722DCB6A191EEAB
1 changed files with 21 additions and 2 deletions

View File

@ -6,11 +6,12 @@
//
use crate::utils::{in_macro, span_lint};
use if_chain::if_chain;
use rustc::hir;
use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
use rustc::ty;
use rustc::{declare_tool_lint, lint_array};
use syntax::ast;
use syntax::ast::{self, MetaItem, MetaItemKind};
use syntax::attr;
use syntax::source_map::Span;
@ -52,6 +53,22 @@ impl MissingDoc {
*self.doc_hidden_stack.last().expect("empty doc_hidden_stack")
}
#[allow(clippy::needless_bool)]
fn has_include(meta: Option<MetaItem>) -> bool {
if_chain! {
if let Some(meta) = meta;
if let MetaItemKind::List(list) = meta.node;
if let Some(meta) = list.get(0);
if let Some(name) = meta.name();
if name == "include";
then {
true
} else {
false
}
}
}
fn check_missing_docs_attrs(
&self,
cx: &LateContext<'_, '_>,
@ -74,7 +91,9 @@ impl MissingDoc {
return;
}
let has_doc = attrs.iter().any(|a| a.is_value_str() && a.name() == "doc");
let has_doc = attrs
.iter()
.any(|a| a.name() == "doc" && (a.is_value_str() || Self::has_include(a.meta())));
if !has_doc {
span_lint(
cx,