Skip to content

Commit 31bb3c0

Browse files
Move Res check into should_ignore_res
1 parent f45961b commit 31bb3c0

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use thin_vec::ThinVec;
4141

4242
use crate::core::{self, DocContext, ImplTraitParam};
4343
use crate::formats::item_type::ItemType;
44-
use crate::visit_ast::Module as DocModule;
44+
use crate::visit_ast::{should_ignore_res, Module as DocModule};
4545

4646
use utils::*;
4747

@@ -2809,7 +2809,7 @@ fn clean_use_statement_inner<'tcx>(
28092809
cx: &mut DocContext<'tcx>,
28102810
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
28112811
) -> Vec<Item> {
2812-
if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = path.res {
2812+
if should_ignore_res(path.res) {
28132813
return Vec::new();
28142814
}
28152815
// We need this comparison because some imports (for std types for example)

src/librustdoc/visit_ast.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ pub(crate) fn inherits_doc_hidden(
100100
false
101101
}
102102

103+
#[inline]
104+
pub(crate) fn should_ignore_res(res: Res) -> bool {
105+
matches!(res, Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..))
106+
}
107+
103108
pub(crate) struct RustdocVisitor<'a, 'tcx> {
104109
cx: &'a mut core::DocContext<'tcx>,
105110
view_item_stack: LocalDefIdSet,
@@ -466,7 +471,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
466471
for &res in &path.res {
467472
// Struct and variant constructors and proc macro stubs always show up alongside
468473
// their definitions, we've already processed them so just discard these.
469-
if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = res {
474+
if should_ignore_res(res) {
470475
continue;
471476
}
472477

0 commit comments

Comments
 (0)