Skip to content

Commit 238bcc9

Browse files
committed
rustdoc: box ItemKind::Trait
This reduces the memory consumption of ItemKind.
1 parent 2aa4aa7 commit 238bcc9

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

src/librustdoc/clean/inline.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub(crate) fn try_inline(
6262
Res::Def(DefKind::Trait, did) => {
6363
record_extern_fqn(cx, did, ItemType::Trait);
6464
build_impls(cx, Some(parent_module), did, attrs, &mut ret);
65-
clean::TraitItem(build_external_trait(cx, did))
65+
clean::TraitItem(Box::new(build_external_trait(cx, did)))
6666
}
6767
Res::Def(DefKind::Fn, did) => {
6868
record_extern_fqn(cx, did, ItemType::Function);

src/librustdoc/clean/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1951,12 +1951,12 @@ fn clean_maybe_renamed_item<'tcx>(
19511951
.map(|ti| clean_trait_item(cx.tcx.hir().trait_item(ti.id), cx))
19521952
.collect();
19531953

1954-
TraitItem(Trait {
1954+
TraitItem(Box::new(Trait {
19551955
def_id,
19561956
items,
19571957
generics: clean_generics(generics, cx),
19581958
bounds: bounds.iter().filter_map(|x| clean_generic_bound(x, cx)).collect(),
1959-
})
1959+
}))
19601960
}
19611961
ItemKind::ExternCrate(orig_name) => {
19621962
return clean_extern_crate(item, name, orig_name, cx);

src/librustdoc/clean/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ pub(crate) enum ItemKind {
727727
OpaqueTyItem(OpaqueTy),
728728
StaticItem(Static),
729729
ConstantItem(Constant),
730-
TraitItem(Trait),
730+
TraitItem(Box<Trait>),
731731
TraitAliasItem(TraitAlias),
732732
ImplItem(Box<Impl>),
733733
/// A required method in a trait declaration meaning it's only a function signature.
@@ -2497,7 +2497,7 @@ mod size_asserts {
24972497
static_assert_size!(GenericArgs, 32);
24982498
static_assert_size!(GenericParamDef, 56);
24992499
static_assert_size!(Item, 56);
2500-
static_assert_size!(ItemKind, 112);
2500+
static_assert_size!(ItemKind, 96);
25012501
static_assert_size!(PathSegment, 40);
25022502
static_assert_size!(Type, 56);
25032503
}

src/librustdoc/formats/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
227227
if let clean::TraitItem(ref t) = *item.kind {
228228
self.cache.traits.entry(item.item_id.expect_def_id()).or_insert_with(|| {
229229
clean::TraitWithExtraInfo {
230-
trait_: t.clone(),
230+
trait_: *t.clone(),
231231
is_notable: item.attrs.has_doc_flag(sym::notable_trait),
232232
}
233233
});

src/librustdoc/json/conversions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum {
248248
VariantItem(v) => ItemEnum::Variant(v.into_tcx(tcx)),
249249
FunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)),
250250
ForeignFunctionItem(f) => ItemEnum::Function(from_function(f, header.unwrap(), tcx)),
251-
TraitItem(t) => ItemEnum::Trait(t.into_tcx(tcx)),
251+
TraitItem(t) => ItemEnum::Trait((*t).into_tcx(tcx)),
252252
TraitAliasItem(t) => ItemEnum::TraitAlias(t.into_tcx(tcx)),
253253
MethodItem(m, _) => ItemEnum::Method(from_function_method(m, true, header.unwrap(), tcx)),
254254
TyMethodItem(m) => ItemEnum::Method(from_function_method(m, false, header.unwrap(), tcx)),

0 commit comments

Comments
 (0)