Skip to content

Commit 0b82a25

Browse files
committed
Box Function to reduce the size of ItemKind
1 parent 3d80566 commit 0b82a25

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/librustdoc/clean/inline.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ crate fn try_inline(
6262
}
6363
Res::Def(DefKind::Fn, did) => {
6464
record_extern_fqn(cx, did, clean::TypeKind::Function);
65-
clean::FunctionItem(build_external_function(cx, did))
65+
clean::FunctionItem(box build_external_function(cx, did))
6666
}
6767
Res::Def(DefKind::Struct, did) => {
6868
record_extern_fqn(cx, did, clean::TypeKind::Struct);
@@ -77,7 +77,7 @@ crate fn try_inline(
7777
Res::Def(DefKind::TyAlias, did) => {
7878
record_extern_fqn(cx, did, clean::TypeKind::Typedef);
7979
ret.extend(build_impls(cx, Some(parent_module), did, attrs));
80-
clean::TypedefItem(build_type_alias(cx, did), false)
80+
clean::TypedefItem(box build_type_alias(cx, did), false)
8181
}
8282
Res::Def(DefKind::Enum, did) => {
8383
record_extern_fqn(cx, did, clean::TypeKind::Enum);

src/librustdoc/clean/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ fn clean_fn_or_proc_macro(
919919
} else {
920920
hir::Constness::NotConst
921921
};
922-
FunctionItem(func)
922+
FunctionItem(box func)
923923
}
924924
}
925925
}
@@ -1076,7 +1076,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
10761076
{
10771077
m.header.constness = hir::Constness::NotConst;
10781078
}
1079-
MethodItem(m, None)
1079+
MethodItem(box m, None)
10801080
}
10811081
hir::TraitItemKind::Fn(ref sig, hir::TraitFn::Required(ref names)) => {
10821082
let (generics, decl) = enter_impl_trait(cx, || {
@@ -1090,7 +1090,7 @@ impl Clean<Item> for hir::TraitItem<'_> {
10901090
{
10911091
t.header.constness = hir::Constness::NotConst;
10921092
}
1093-
TyMethodItem(t)
1093+
TyMethodItem(box t)
10941094
}
10951095
hir::TraitItemKind::Type(ref bounds, ref default) => {
10961096
AssocTypeItem(bounds.clean(cx), default.clean(cx))
@@ -1116,12 +1116,12 @@ impl Clean<Item> for hir::ImplItem<'_> {
11161116
{
11171117
m.header.constness = hir::Constness::NotConst;
11181118
}
1119-
MethodItem(m, Some(self.defaultness))
1119+
MethodItem(box m, Some(self.defaultness))
11201120
}
11211121
hir::ImplItemKind::TyAlias(ref ty) => {
11221122
let type_ = ty.clean(cx);
11231123
let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));
1124-
TypedefItem(Typedef { type_, generics: Generics::default(), item_type }, true)
1124+
TypedefItem(box Typedef { type_, generics: Generics::default(), item_type }, true)
11251125
}
11261126
};
11271127
Item::from_def_id_and_parts(local_did, Some(self.ident.name.clean(cx)), inner, cx)
@@ -1185,7 +1185,7 @@ impl Clean<Item> for ty::AssocItem {
11851185
ty::TraitContainer(_) => None,
11861186
};
11871187
MethodItem(
1188-
Function {
1188+
box Function {
11891189
generics,
11901190
decl,
11911191
header: hir::FnHeader {
@@ -1200,7 +1200,7 @@ impl Clean<Item> for ty::AssocItem {
12001200
defaultness,
12011201
)
12021202
} else {
1203-
TyMethodItem(Function {
1203+
TyMethodItem(box Function {
12041204
generics,
12051205
decl,
12061206
header: hir::FnHeader {
@@ -2263,7 +2263,7 @@ impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Symbol>) {
22632263
(generics.clean(cx), (&**decl, &names[..]).clean(cx))
22642264
});
22652265
let (all_types, ret_types) = get_all_types(&generics, &decl, cx);
2266-
ForeignFunctionItem(Function {
2266+
ForeignFunctionItem(box Function {
22672267
decl,
22682268
generics,
22692269
header: hir::FnHeader {

src/librustdoc/clean/types.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ crate enum ItemKind {
305305
StructItem(Struct),
306306
UnionItem(Union),
307307
EnumItem(Enum),
308-
FunctionItem(Function),
308+
FunctionItem(Box<Function>),
309309
ModuleItem(Module),
310310
TypedefItem(Typedef, bool /* is associated type */),
311311
OpaqueTyItem(OpaqueTy),
@@ -318,13 +318,13 @@ crate enum ItemKind {
318318
ImplItem(Box<Impl>),
319319
/// A method signature only. Used for required methods in traits (ie,
320320
/// non-default-methods).
321-
TyMethodItem(Function),
321+
TyMethodItem(Box<Function>),
322322
/// A method with a body.
323-
MethodItem(Function, Option<hir::Defaultness>),
323+
MethodItem(Box<Function>, Option<hir::Defaultness>),
324324
StructFieldItem(Type),
325325
VariantItem(Variant),
326326
/// `fn`s from an extern block
327-
ForeignFunctionItem(Function),
327+
ForeignFunctionItem(Box<Function>),
328328
/// `static`s from an extern block
329329
ForeignStaticItem(Static),
330330
/// `type`s from an extern block

src/librustdoc/json/conversions.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,12 @@ impl From<clean::ItemKind> for ItemEnum {
169169
StructFieldItem(f) => ItemEnum::StructFieldItem(f.into()),
170170
EnumItem(e) => ItemEnum::EnumItem(e.into()),
171171
VariantItem(v) => ItemEnum::VariantItem(v.into()),
172-
FunctionItem(f) => ItemEnum::FunctionItem(f.into()),
173-
ForeignFunctionItem(f) => ItemEnum::FunctionItem(f.into()),
172+
FunctionItem(box f) => ItemEnum::FunctionItem(f.into()),
173+
ForeignFunctionItem(box f) => ItemEnum::FunctionItem(f.into()),
174174
TraitItem(t) => ItemEnum::TraitItem(t.into()),
175175
TraitAliasItem(t) => ItemEnum::TraitAliasItem(t.into()),
176-
MethodItem(m, _) => ItemEnum::MethodItem(m.into()),
177-
TyMethodItem(m) => ItemEnum::MethodItem(m.into()),
176+
MethodItem(box m, _) => ItemEnum::MethodItem(m.into()),
177+
TyMethodItem(box m) => ItemEnum::MethodItem(m.into()),
178178
ImplItem(box i) => ItemEnum::ImplItem(i.into()),
179179
StaticItem(s) => ItemEnum::StaticItem(s.into()),
180180
ForeignStaticItem(s) => ItemEnum::StaticItem(s.into()),

0 commit comments

Comments
 (0)