Move visibility check inside the should_have_doc_example function
This commit is contained in:
parent
91095b1be5
commit
186f13914a
@ -53,20 +53,22 @@ fn add_test(&mut self, _: String, config: LangString, _: usize) {
|
||||
}
|
||||
|
||||
crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> bool {
|
||||
if matches!(
|
||||
*item.kind,
|
||||
clean::StructFieldItem(_)
|
||||
| clean::VariantItem(_)
|
||||
| clean::AssocConstItem(_, _)
|
||||
| clean::AssocTypeItem(_, _)
|
||||
| clean::TypedefItem(_, _)
|
||||
| clean::StaticItem(_)
|
||||
| clean::ConstantItem(_)
|
||||
| clean::ExternCrateItem(_, _)
|
||||
| clean::ImportItem(_)
|
||||
| clean::PrimitiveItem(_)
|
||||
| clean::KeywordItem(_)
|
||||
) {
|
||||
if !cx.renderinfo.borrow().access_levels.is_public(item.def_id)
|
||||
|| matches!(
|
||||
*item.kind,
|
||||
clean::StructFieldItem(_)
|
||||
| clean::VariantItem(_)
|
||||
| clean::AssocConstItem(_, _)
|
||||
| clean::AssocTypeItem(_, _)
|
||||
| clean::TypedefItem(_, _)
|
||||
| clean::StaticItem(_)
|
||||
| clean::ConstantItem(_)
|
||||
| clean::ExternCrateItem(_, _)
|
||||
| clean::ImportItem(_)
|
||||
| clean::PrimitiveItem(_)
|
||||
| clean::KeywordItem(_)
|
||||
)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.def_id.expect_local());
|
||||
@ -93,9 +95,7 @@ fn add_test(&mut self, _: String, config: LangString, _: usize) {
|
||||
find_testable_code(&dox, &mut tests, ErrorCodes::No, false, None);
|
||||
|
||||
if tests.found_tests == 0 && cx.tcx.sess.is_nightly_build() {
|
||||
if cx.renderinfo.borrow().access_levels.is_public(item.def_id)
|
||||
&& should_have_doc_example(cx, &item)
|
||||
{
|
||||
if should_have_doc_example(cx, &item) {
|
||||
debug!("reporting error for {:?} (hir_id={:?})", item, hir_id);
|
||||
let sp = span_of_attrs(&item.attrs).unwrap_or(item.source.span());
|
||||
cx.tcx.struct_span_lint_hir(
|
||||
|
@ -35,9 +35,6 @@ fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<String> {
|
||||
if cx.tcx.hir().attrs(node).lists(sym::doc).has_word(sym::hidden) {
|
||||
return true;
|
||||
}
|
||||
if node == hir::CRATE_HIR_ID {
|
||||
break;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user