use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::ty;
use rustc_session::{declare_tool_lint, impl_lint_pass};
+use rustc_span::def_id::CRATE_DEF_ID;
use rustc_span::source_map::Span;
use rustc_span::sym;
declare_clippy_lint! {
- /// **What it does:** Warns if there is missing doc for any documentable item
+ /// ### What it does
+ /// Warns if there is missing doc for any documentable item
/// (public or private).
///
- /// **Why is this bad?** Doc is good. *rustc* has a `MISSING_DOCS`
+ /// ### Why is this bad?
+ /// Doc is good. *rustc* has a `MISSING_DOCS`
/// allowed-by-default lint for
/// public members, but has no way to enforce documentation of private items.
/// This lint fixes that.
- ///
- /// **Known problems:** None.
+ #[clippy::version = "pre 1.29.0"]
pub MISSING_DOCS_IN_PRIVATE_ITEMS,
restriction,
"detects missing documentation for public and private members"
return;
}
- let has_doc = attrs.iter().any(|a| {
- a.is_doc_comment() || a.doc_str().is_some() || a.value_str().is_some() || Self::has_include(a.meta())
- });
+ let has_doc = attrs
+ .iter()
+ .any(|a| a.doc_str().is_some() || Self::has_include(a.meta()));
if !has_doc {
span_lint(
cx,
self.doc_hidden_stack.pop().expect("empty doc_hidden_stack");
}
- fn check_crate(&mut self, cx: &LateContext<'tcx>, krate: &'tcx hir::Crate<'_>) {
+ fn check_crate(&mut self, cx: &LateContext<'tcx>) {
let attrs = cx.tcx.hir().attrs(hir::CRATE_HIR_ID);
- self.check_missing_docs_attrs(cx, attrs, krate.item.inner, "the", "crate");
+ self.check_missing_docs_attrs(cx, attrs, cx.tcx.def_span(CRATE_DEF_ID), "the", "crate");
}
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
},
hir::ItemKind::Const(..)
| hir::ItemKind::Enum(..)
+ | hir::ItemKind::Macro(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Static(..)
| hir::ItemKind::Struct(..)