Skip to content

Commit 177b3b2

Browse files
committed
Add doc(include = ...) detection to missing_docs_in_private_items
1 parent 7298929 commit 177b3b2

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

clippy_lints/src/missing_doc.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
//
77

88
use crate::utils::{in_macro, span_lint};
9+
use if_chain::if_chain;
910
use rustc::hir;
1011
use rustc::lint::{LateContext, LateLintPass, LintArray, LintContext, LintPass};
1112
use rustc::ty;
1213
use rustc::{declare_tool_lint, lint_array};
13-
use syntax::ast;
14+
use syntax::ast::{self, MetaItem, MetaItemKind};
1415
use syntax::attr;
1516
use syntax::source_map::Span;
1617

@@ -52,6 +53,22 @@ impl MissingDoc {
5253
*self.doc_hidden_stack.last().expect("empty doc_hidden_stack")
5354
}
5455

56+
#[allow(clippy::needless_bool)]
57+
fn has_include(meta: Option<MetaItem>) -> bool {
58+
if_chain! {
59+
if let Some(meta) = meta;
60+
if let MetaItemKind::List(list) = meta.node;
61+
if let Some(meta) = list.get(0);
62+
if let Some(name) = meta.name();
63+
if name == "include";
64+
then {
65+
true
66+
} else {
67+
false
68+
}
69+
}
70+
}
71+
5572
fn check_missing_docs_attrs(
5673
&self,
5774
cx: &LateContext<'_, '_>,
@@ -74,7 +91,9 @@ impl MissingDoc {
7491
return;
7592
}
7693

77-
let has_doc = attrs.iter().any(|a| a.is_value_str() && a.name() == "doc");
94+
let has_doc = attrs
95+
.iter()
96+
.any(|a| a.name() == "doc" && (a.is_value_str() || Self::has_include(a.meta())));
7897
if !has_doc {
7998
span_lint(
8099
cx,

0 commit comments

Comments
 (0)