rustdoc: box ItemKind::Trait

This reduces the memory consumption of ItemKind.
This commit is contained in:
Michael Howell 2022-08-16 13:08:54 -07:00
parent 2aa4aa70dd
commit 238bcc940f
5 changed files with 7 additions and 7 deletions

View File

@ -62,7 +62,7 @@ pub(crate) fn try_inline(
Res::Def(DefKind::Trait, did) => {
record_extern_fqn(cx, did, ItemType::Trait);
build_impls(cx, Some(parent_module), did, attrs, &mut ret);
clean::TraitItem(build_external_trait(cx, did))
clean::TraitItem(Box::new(build_external_trait(cx, did)))
}
Res::Def(DefKind::Fn, did) => {
record_extern_fqn(cx, did, ItemType::Function);

View File

@ -1951,12 +1951,12 @@ fn clean_maybe_renamed_item<'tcx>(
.map(|ti| clean_trait_item(cx.tcx.hir().trait_item(ti.id), cx))
.collect();
TraitItem(Trait {
TraitItem(Box::new(Trait {
def_id,
items,
generics: clean_generics(generics, cx),
bounds: bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
})
}))
}
ItemKind::ExternCrate(orig_name) => {
return clean_extern_crate(item, name, orig_name, cx);

View File

@ -727,7 +727,7 @@ pub(crate) enum ItemKind {
OpaqueTyItem(OpaqueTy),
StaticItem(Static),
ConstantItem(Constant),
TraitItem(Trait),
TraitItem(Box<Trait>),
TraitAliasItem(TraitAlias),
ImplItem(Box<Impl>),
/// A required method in a trait declaration meaning it's only a function signature.
@ -2497,7 +2497,7 @@ mod size_asserts {
static_assert_size!(GenericArgs, 32);
static_assert_size!(GenericParamDef, 56);
static_assert_size!(Item, 56);
static_assert_size!(ItemKind, 112);
static_assert_size!(ItemKind, 96);
static_assert_size!(PathSegment, 40);
static_assert_size!(Type, 56);
}

View File

@ -227,7 +227,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
if let clean::TraitItem(ref t) = *item.kind {
self.cache.traits.entry(item.item_id.expect_def_id()).or_insert_with(|| {
clean::TraitWithExtraInfo {
trait_: t.clone(),
trait_: *t.clone(),
is_notable: item.attrs.has_doc_flag(sym::notable_trait),
}
});

View File

@ -248,7 +248,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
VariantItem(v) => ItemEnum::Variant(v.into_tcx(tcx)),
FunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)),
ForeignFunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)),
TraitItem(t) => ItemEnum::Trait(t.into_tcx(tcx)),
TraitItem(t) => ItemEnum::Trait((*t).into_tcx(tcx)),
TraitAliasItem(t) => ItemEnum::TraitAlias(t.into_tcx(tcx)),
MethodItem(m, _) => ItemEnum::Method(from_function_method(m, true, header.unwrap(), tcx)),
TyMethodItem(m) => ItemEnum::Method(from_function_method(m, false, header.unwrap(), tcx)),