Skip to content

Commit 1476b39

Browse files
committed
Skip lint check when item is not fully public
1 parent 62113f6 commit 1476b39

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/librustdoc/passes/lint/redundant_explicit_links.rs

+19
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::clean::Item;
1313
use crate::core::DocContext;
1414
use crate::html::markdown::main_body_opts;
1515
use crate::passes::source_span_for_markdown_range;
16+
use crate::visit_ast::inherits_doc_hidden;
1617

1718
#[derive(Debug)]
1819
struct LinkData {
@@ -39,6 +40,24 @@ pub(crate) fn visit_item(cx: &DocContext<'_>, item: &Item) {
3940
return;
4041
}
4142

43+
let Some(item_id) = item.def_id() else {
44+
return;
45+
};
46+
let Some(local_item_id) = item_id.as_local() else {
47+
return;
48+
};
49+
50+
let is_hidden = !cx.render_options.document_hidden
51+
&& (item.is_doc_hidden() || inherits_doc_hidden(cx.tcx, local_item_id, None));
52+
if is_hidden {
53+
return;
54+
}
55+
let is_private = !cx.render_options.document_private
56+
&& !cx.cache.effective_visibilities.is_directly_public(cx.tcx, item_id);
57+
if is_private {
58+
return;
59+
}
60+
4261
check_redundant_explicit_link(cx, item, hir_id, &doc);
4362
}
4463

0 commit comments

Comments
 (0)