about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCamelid <camelidcamel@gmail.com>2020-12-25 16:35:28 -0800
committerCamelid <camelidcamel@gmail.com>2020-12-25 16:35:28 -0800
commiteaf851288ed31090afd924eeb22f5e0f202151d4 (patch)
tree1154f938a3e781b63b0a910d6acba48c77777ada
parent4b1b277cf90886466e2e0dc5017ea535ef5e00ce (diff)
downloadrust-eaf851288ed31090afd924eeb22f5e0f202151d4.tar.gz
rust-eaf851288ed31090afd924eeb22f5e0f202151d4.zip
Simplify loop and remove old debugging code
Co-authored-by: Joshua Nelson <jyn514@gmail.com>
-rw-r--r--src/librustdoc/clean/utils.rs19
1 files changed, 5 insertions, 14 deletions
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 @@ crate fn find_closest_parent_module(tcx: TyCtxt<'_>, def_id: DefId) -> Option<De
         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
     }
 }