return;
}
+ // If the method is an impl for an item with docs_hidden, don't doc.
+ if method_context(cx, impl_item.hir_id()) == MethodLateContext::PlainImpl {
+ let parent = cx.tcx.hir().get_parent_did(impl_item.hir_id());
+ let impl_ty = cx.tcx.type_of(parent);
+ let outerdef = match impl_ty.kind() {
+ ty::Adt(def, _) => Some(def.did),
+ ty::Foreign(def_id) => Some(*def_id),
+ _ => None,
+ };
+ let is_hidden = match outerdef {
+ Some(id) => cx.tcx.is_doc_hidden(id),
+ None => false,
+ };
+ if is_hidden {
+ return;
+ }
+ }
+
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
self.check_missing_docs_attrs(cx, impl_item.def_id, impl_item.span, article, desc);
}
// Find calls to `mem::{uninitialized,zeroed}` methods.
if let hir::ExprKind::Path(ref qpath) = path_expr.kind {
let def_id = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id()?;
-
- if cx.tcx.is_diagnostic_item(sym::mem_zeroed, def_id) {
- return Some(InitKind::Zeroed);
- } else if cx.tcx.is_diagnostic_item(sym::mem_uninitialized, def_id) {
- return Some(InitKind::Uninit);
- } else if cx.tcx.is_diagnostic_item(sym::transmute, def_id) && is_zero(&args[0])
- {
- return Some(InitKind::Zeroed);
+ match cx.tcx.get_diagnostic_name(def_id) {
+ Some(sym::mem_zeroed) => return Some(InitKind::Zeroed),
+ Some(sym::mem_uninitialized) => return Some(InitKind::Uninit),
+ Some(sym::transmute) if is_zero(&args[0]) => return Some(InitKind::Zeroed),
+ _ => {}
}
}
} else if let hir::ExprKind::MethodCall(_, _, ref args, _) = expr.kind {
if let hir::ExprKind::Call(ref path_expr, _) = args[0].kind {
if let hir::ExprKind::Path(ref qpath) = path_expr.kind {
let def_id = cx.qpath_res(qpath, path_expr.hir_id).opt_def_id()?;
-
- if cx.tcx.is_diagnostic_item(sym::maybe_uninit_zeroed, def_id) {
- return Some(InitKind::Zeroed);
- } else if cx.tcx.is_diagnostic_item(sym::maybe_uninit_uninit, def_id) {
- return Some(InitKind::Uninit);
+ match cx.tcx.get_diagnostic_name(def_id) {
+ Some(sym::maybe_uninit_zeroed) => return Some(InitKind::Zeroed),
+ Some(sym::maybe_uninit_uninit) => return Some(InitKind::Uninit),
+ _ => {}
}
}
}
rustc_hir::ExprKind::Call(ref path, _) => {
if let rustc_hir::ExprKind::Path(ref qpath) = path.kind {
if let Some(def_id) = cx.qpath_res(qpath, path.hir_id).opt_def_id() {
- return cx.tcx.is_diagnostic_item(sym::ptr_null, def_id)
- || cx.tcx.is_diagnostic_item(sym::ptr_null_mut, def_id);
+ return matches!(
+ cx.tcx.get_diagnostic_name(def_id),
+ Some(sym::ptr_null | sym::ptr_null_mut)
+ );
}
}
}