Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit eaf8512

Browse files
camelidjyn514
andcommitted
Simplify loop and remove old debugging code
Co-authored-by: Joshua Nelson <[email protected]>
1 parent 4b1b277 commit eaf8512

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/librustdoc/clean/utils.rs

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -636,21 +636,12 @@ crate fn find_closest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<De
636636
let mut current = def_id;
637637
// The immediate parent might not always be a module.
638638
// Find the first parent which is.
639-
loop {
640-
if let Some(parent) = tcx.parent(current) {
641-
if tcx.def_kind(parent) == DefKind::Mod {
642-
break Some(parent);
643-
}
644-
current = parent;
645-
} else {
646-
debug!(
647-
"{:?} has no parent (kind={:?}, original was {:?})",
648-
current,
649-
tcx.def_kind(current),
650-
def_id
651-
);
652-
break None;
639+
while let Some(parent) = tcx.parent(current) {
640+
if tcx.def_kind(parent) == DefKind::Mod {
641+
return Some(parent);
653642
}
643+
current = parent;
654644
}
645+
None
655646
}
656647
}

0 commit comments

Comments
 (0)