Skip to content

Commit 66aa2ef

Browse files
Move Res check into should_ignore_res
1 parent 155a5c2 commit 66aa2ef

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

@@ -2679,7 +2679,7 @@ fn clean_use_statement_inner<'tcx>(
26792679
cx: &mut DocContext<'tcx>,
26802680
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
26812681
) -> Vec<Item> {
2682-
if let Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = path.res {
2682+
if should_ignore_res(path.res) {
26832683
return Vec::new();
26842684
}
26852685
// 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)