rustdoc: box ItemKind::Trait
This reduces the memory consumption of ItemKind.
This commit is contained in:
parent
2aa4aa70dd
commit
238bcc940f
5 changed files with 7 additions and 7 deletions
|
@ -62,7 +62,7 @@ pub(crate) fn try_inline(
|
||||||
Res::Def(DefKind::Trait, did) => {
|
Res::Def(DefKind::Trait, did) => {
|
||||||
record_extern_fqn(cx, did, ItemType::Trait);
|
record_extern_fqn(cx, did, ItemType::Trait);
|
||||||
build_impls(cx, Some(parent_module), did, attrs, &mut ret);
|
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) => {
|
Res::Def(DefKind::Fn, did) => {
|
||||||
record_extern_fqn(cx, did, ItemType::Function);
|
record_extern_fqn(cx, did, ItemType::Function);
|
||||||
|
|
|
@ -1951,12 +1951,12 @@ fn clean_maybe_renamed_item<'tcx>(
|
||||||
.map(|ti| clean_trait_item(cx.tcx.hir().trait_item(ti.id), cx))
|
.map(|ti| clean_trait_item(cx.tcx.hir().trait_item(ti.id), cx))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
TraitItem(Trait {
|
TraitItem(Box::new(Trait {
|
||||||
def_id,
|
def_id,
|
||||||
items,
|
items,
|
||||||
generics: clean_generics(generics, cx),
|
generics: clean_generics(generics, cx),
|
||||||
bounds: bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
|
bounds: bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
ItemKind::ExternCrate(orig_name) => {
|
ItemKind::ExternCrate(orig_name) => {
|
||||||
return clean_extern_crate(item, name, orig_name, cx);
|
return clean_extern_crate(item, name, orig_name, cx);
|
||||||
|
|
|
@ -727,7 +727,7 @@ pub(crate) enum ItemKind {
|
||||||
OpaqueTyItem(OpaqueTy),
|
OpaqueTyItem(OpaqueTy),
|
||||||
StaticItem(Static),
|
StaticItem(Static),
|
||||||
ConstantItem(Constant),
|
ConstantItem(Constant),
|
||||||
TraitItem(Trait),
|
TraitItem(Box<Trait>),
|
||||||
TraitAliasItem(TraitAlias),
|
TraitAliasItem(TraitAlias),
|
||||||
ImplItem(Box<Impl>),
|
ImplItem(Box<Impl>),
|
||||||
/// A required method in a trait declaration meaning it's only a function signature.
|
/// 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!(GenericArgs, 32);
|
||||||
static_assert_size!(GenericParamDef, 56);
|
static_assert_size!(GenericParamDef, 56);
|
||||||
static_assert_size!(Item, 56);
|
static_assert_size!(Item, 56);
|
||||||
static_assert_size!(ItemKind, 112);
|
static_assert_size!(ItemKind, 96);
|
||||||
static_assert_size!(PathSegment, 40);
|
static_assert_size!(PathSegment, 40);
|
||||||
static_assert_size!(Type, 56);
|
static_assert_size!(Type, 56);
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
|
||||||
if let clean::TraitItem(ref t) = *item.kind {
|
if let clean::TraitItem(ref t) = *item.kind {
|
||||||
self.cache.traits.entry(item.item_id.expect_def_id()).or_insert_with(|| {
|
self.cache.traits.entry(item.item_id.expect_def_id()).or_insert_with(|| {
|
||||||
clean::TraitWithExtraInfo {
|
clean::TraitWithExtraInfo {
|
||||||
trait_: t.clone(),
|
trait_: *t.clone(),
|
||||||
is_notable: item.attrs.has_doc_flag(sym::notable_trait),
|
is_notable: item.attrs.has_doc_flag(sym::notable_trait),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -248,7 +248,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
|
||||||
VariantItem(v) => ItemEnum::Variant(v.into_tcx(tcx)),
|
VariantItem(v) => ItemEnum::Variant(v.into_tcx(tcx)),
|
||||||
FunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)),
|
FunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)),
|
||||||
ForeignFunctionItem(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)),
|
TraitAliasItem(t) => ItemEnum::TraitAlias(t.into_tcx(tcx)),
|
||||||
MethodItem(m, _) => ItemEnum::Method(from_function_method(m, true, header.unwrap(), 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)),
|
TyMethodItem(m) => ItemEnum::Method(from_function_method(m, false, header.unwrap(), tcx)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue