inline ItemId method, clarify comments a bit

This commit is contained in:
Rune Tynan 2022-01-13 14:40:28 -05:00
parent 74f0e582be
commit a6aa3cb2c1
2 changed files with 10 additions and 11 deletions

View file

@ -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 {

View file

@ -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());
}