Simplify loop and remove old debugging code

Co-authored-by: Joshua Nelson <jyn514@gmail.com>
This commit is contained in:
Camelid 2020-12-25 16:35:28 -08:00
parent 4b1b277cf9
commit eaf851288e

View File

@ -636,21 +636,12 @@ fn print_const_with_custom_print_scalar(cx: &DocContext<'_>, ct: &'tcx ty::Const
let mut current = def_id;
// The immediate parent might not always be a module.
// Find the first parent which is.
loop {
if let Some(parent) = tcx.parent(current) {
if tcx.def_kind(parent) == DefKind::Mod {
break Some(parent);
}
current = parent;
} else {
debug!(
"{:?} has no parent (kind={:?}, original was {:?})",
current,
tcx.def_kind(current),
def_id
);
break None;
while let Some(parent) = tcx.parent(current) {
if tcx.def_kind(parent) == DefKind::Mod {
return Some(parent);
}
current = parent;
}
None
}
}