Skip lint check when item is not fully public

This commit is contained in:
Kyle Lin 2023-07-21 01:21:58 +08:00
parent 62113f6657
commit 1476b39fae

View File

@ -13,6 +13,7 @@ use crate::clean::Item;
use crate::core::DocContext;
use crate::html::markdown::main_body_opts;
use crate::passes::source_span_for_markdown_range;
use crate::visit_ast::inherits_doc_hidden;
#[derive(Debug)]
struct LinkData {
@ -39,6 +40,24 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
return;
}
let Some(item_id) = item.def_id() else {
return;
};
let Some(local_item_id) = item_id.as_local() else {
return;
};
let is_hidden = !cx.render_options.document_hidden
&& (item.is_doc_hidden() || inherits_doc_hidden(cx.tcx, local_item_id, None));
if is_hidden {
return;
}
let is_private = !cx.render_options.document_private
&& !cx.cache.effective_visibilities.is_directly_public(cx.tcx, item_id);
if is_private {
return;
}
check_redundant_explicit_link(cx, item, hir_id, &doc);
}