From a6aa3cb2c10c986eb231378e154766ce38f99a49 Mon Sep 17 00:00:00 2001 From: Rune Tynan Date: Thu, 13 Jan 2022 14:40:28 -0500 Subject: [PATCH] inline ItemId method, clarify comments a bit --- src/librustdoc/clean/types.rs | 8 -------- src/librustdoc/json/mod.rs | 13 ++++++++++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index c47a2c7ca03f..00c6e38839f5 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -75,14 +75,6 @@ impl ItemId { } } - #[inline] - crate fn is_local_impl(self) -> bool { - match self { - ItemId::Blanket { impl_id, .. } => impl_id.is_local(), - ItemId::Auto { .. } | ItemId::DefId(_) | ItemId::Primitive(_, _) => false, - } - } - #[inline] #[track_caller] crate fn expect_def_id(self) -> DefId { diff --git a/src/librustdoc/json/mod.rs b/src/librustdoc/json/mod.rs index c1efefc322e0..0f80c8a5b4cc 100644 --- a/src/librustdoc/json/mod.rs +++ b/src/librustdoc/json/mod.rs @@ -171,10 +171,17 @@ impl<'tcx> FormatRenderer<'tcx> for JsonRenderer<'tcx> { /// the hashmap because certain items (traits and types) need to have their mappings for trait /// implementations filled out before they're inserted. fn item(&mut self, item: clean::Item) -> Result<(), Error> { + // We skip children of local blanket implementations, as we'll have already seen the actual + // generic impl, and the generated ones don't need documenting. + let local_blanket_impl = match item.def_id { + clean::ItemId::Blanket { impl_id, .. } => impl_id.is_local(), + clean::ItemId::Auto { .. } + | clean::ItemId::DefId(_) + | clean::ItemId::Primitive(_, _) => false, + }; + // Flatten items that recursively store other items - // We skip local blanket implementations, as we'll have already seen the actual generic - // impl, and the generated ones don't need documenting. - if !item.def_id.is_local_impl() { + if !local_blanket_impl { item.kind.inner_items().for_each(|i| self.item(i.clone()).unwrap()); }