diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index 4b9541b7e14..b49ed07f8e8 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -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 } }