diff options
| author | xFrednet <xFrednet@gmail.com> | 2022-05-20 20:37:38 +0200 |
|---|---|---|
| committer | xFrednet <xFrednet@gmail.com> | 2022-05-20 20:47:31 +0200 |
| commit | 4e6cf0036e5e7afdc4fe86cccc99482ff4cf71bf (patch) | |
| tree | c0de46a0482ccc460d4789e23b4d2abb5bf17787 /clippy_lints/src/missing_doc.rs | |
| parent | 01421e0cbda66655e25d48c1c72c2dcbe77040c2 (diff) | |
| parent | 6f26383f8ec8dfe89858876eac127161d148eb13 (diff) | |
| download | rust-4e6cf0036e5e7afdc4fe86cccc99482ff4cf71bf.tar.gz rust-4e6cf0036e5e7afdc4fe86cccc99482ff4cf71bf.zip | |
Merge remote-tracking branch 'upstream/master' into rustup
Diffstat (limited to 'clippy_lints/src/missing_doc.rs')
| -rw-r--r-- | clippy_lints/src/missing_doc.rs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/clippy_lints/src/missing_doc.rs b/clippy_lints/src/missing_doc.rs index a20377f320b..b99052e66ba 100644 --- a/clippy_lints/src/missing_doc.rs +++ b/clippy_lints/src/missing_doc.rs @@ -7,7 +7,8 @@ use clippy_utils::attrs::is_doc_hidden; use clippy_utils::diagnostics::span_lint; -use rustc_ast::ast; +use if_chain::if_chain; +use rustc_ast::ast::{self, MetaItem, MetaItemKind}; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::ty::{self, DefIdTree}; @@ -57,6 +58,20 @@ impl MissingDoc { *self.doc_hidden_stack.last().expect("empty doc_hidden_stack") } + fn has_include(meta: Option<MetaItem>) -> bool { + if_chain! { + if let Some(meta) = meta; + if let MetaItemKind::List(list) = meta.kind; + if let Some(meta) = list.get(0); + if let Some(name) = meta.ident(); + then { + name.name == sym::include + } else { + false + } + } + } + fn check_missing_docs_attrs( &self, cx: &LateContext<'_>, @@ -80,7 +95,9 @@ impl MissingDoc { return; } - let has_doc = attrs.iter().any(|a| a.doc_str().is_some()); + let has_doc = attrs + .iter() + .any(|a| a.doc_str().is_some() || Self::has_include(a.meta())); if !has_doc { span_lint( cx, |
