Box FunctionItem, TyMethodItem, MethodItem, ForeignFunctionItem
This reduces ItemKind size from 160 bytes to 112 bytes
This commit is contained in:
parent
96c051fd07
commit
1116fc164f
4 changed files with 16 additions and 16 deletions
|
@ -218,7 +218,7 @@ pub(crate) fn build_external_trait(cx: &mut DocContext<'_>, did: DefId) -> clean
|
|||
clean::Trait { def_id: did, generics, items: trait_items, bounds: supertrait_bounds }
|
||||
}
|
||||
|
||||
fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> clean::Function {
|
||||
fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> Box<clean::Function> {
|
||||
let sig = cx.tcx.fn_sig(did);
|
||||
|
||||
let predicates = cx.tcx.predicates_of(did);
|
||||
|
@ -228,7 +228,7 @@ fn build_external_function<'tcx>(cx: &mut DocContext<'tcx>, did: DefId) -> clean
|
|||
let decl = clean_fn_decl_from_did_and_sig(cx, Some(did), sig);
|
||||
(generics, decl)
|
||||
});
|
||||
clean::Function { decl, generics }
|
||||
Box::new(clean::Function { decl, generics })
|
||||
}
|
||||
|
||||
fn build_enum(cx: &mut DocContext<'_>, did: DefId) -> clean::Enum {
|
||||
|
|
|
@ -908,7 +908,7 @@ fn clean_function<'tcx>(
|
|||
sig: &hir::FnSig<'tcx>,
|
||||
generics: &hir::Generics<'tcx>,
|
||||
body_id: hir::BodyId,
|
||||
) -> Function {
|
||||
) -> Box<Function> {
|
||||
let (generics, decl) = enter_impl_trait(cx, |cx| {
|
||||
// NOTE: generics must be cleaned before args
|
||||
let generics = generics.clean(cx);
|
||||
|
@ -916,7 +916,7 @@ fn clean_function<'tcx>(
|
|||
let decl = clean_fn_decl_with_args(cx, sig.decl, args);
|
||||
(generics, decl)
|
||||
});
|
||||
Function { decl, generics }
|
||||
Box::new(Function { decl, generics })
|
||||
}
|
||||
|
||||
fn clean_args_from_types_and_names<'tcx>(
|
||||
|
@ -1061,7 +1061,7 @@ impl<'tcx> Clean<'tcx, Item> for hir::TraitItem<'tcx> {
|
|||
let decl = clean_fn_decl_with_args(cx, sig.decl, args);
|
||||
(generics, decl)
|
||||
});
|
||||
TyMethodItem(Function { decl, generics })
|
||||
TyMethodItem(Box::new(Function { decl, generics }))
|
||||
}
|
||||
hir::TraitItemKind::Type(bounds, Some(default)) => {
|
||||
let generics = enter_impl_trait(cx, |cx| self.generics.clean(cx));
|
||||
|
@ -1186,9 +1186,9 @@ impl<'tcx> Clean<'tcx, Item> for ty::AssocItem {
|
|||
ty::ImplContainer(_) => Some(self.defaultness),
|
||||
ty::TraitContainer(_) => None,
|
||||
};
|
||||
MethodItem(Function { generics, decl }, defaultness)
|
||||
MethodItem(Box::new(Function { generics, decl }), defaultness)
|
||||
} else {
|
||||
TyMethodItem(Function { generics, decl })
|
||||
TyMethodItem(Box::new(Function { generics, decl }))
|
||||
}
|
||||
}
|
||||
ty::AssocKind::Type => {
|
||||
|
@ -2243,7 +2243,7 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
|
|||
let decl = clean_fn_decl_with_args(cx, decl, args);
|
||||
(generics, decl)
|
||||
});
|
||||
ForeignFunctionItem(Function { decl, generics })
|
||||
ForeignFunctionItem(Box::new(Function { decl, generics }))
|
||||
}
|
||||
hir::ForeignItemKind::Static(ty, mutability) => {
|
||||
ForeignStaticItem(Static { type_: clean_ty(ty, cx), mutability, expr: None })
|
||||
|
|
|
@ -730,7 +730,7 @@ pub(crate) enum ItemKind {
|
|||
StructItem(Struct),
|
||||
UnionItem(Union),
|
||||
EnumItem(Enum),
|
||||
FunctionItem(Function),
|
||||
FunctionItem(Box<Function>),
|
||||
ModuleItem(Module),
|
||||
TypedefItem(Box<Typedef>),
|
||||
OpaqueTyItem(OpaqueTy),
|
||||
|
@ -740,15 +740,15 @@ pub(crate) enum ItemKind {
|
|||
TraitAliasItem(TraitAlias),
|
||||
ImplItem(Box<Impl>),
|
||||
/// A required method in a trait declaration meaning it's only a function signature.
|
||||
TyMethodItem(Function),
|
||||
TyMethodItem(Box<Function>),
|
||||
/// A method in a trait impl or a provided method in a trait declaration.
|
||||
///
|
||||
/// Compared to [TyMethodItem], it also contains a method body.
|
||||
MethodItem(Function, Option<hir::Defaultness>),
|
||||
MethodItem(Box<Function>, Option<hir::Defaultness>),
|
||||
StructFieldItem(Type),
|
||||
VariantItem(Variant),
|
||||
/// `fn`s from an extern block
|
||||
ForeignFunctionItem(Function),
|
||||
ForeignFunctionItem(Box<Function>),
|
||||
/// `static`s from an extern block
|
||||
ForeignStaticItem(Static),
|
||||
/// `type`s from an extern block
|
||||
|
|
|
@ -602,11 +602,11 @@ impl FromWithTcx<Box<clean::Impl>> for Impl {
|
|||
}
|
||||
|
||||
pub(crate) fn from_function(
|
||||
function: clean::Function,
|
||||
function: Box<clean::Function>,
|
||||
header: rustc_hir::FnHeader,
|
||||
tcx: TyCtxt<'_>,
|
||||
) -> Function {
|
||||
let clean::Function { decl, generics } = function;
|
||||
let clean::Function { decl, generics } = *function;
|
||||
Function {
|
||||
decl: decl.into_tcx(tcx),
|
||||
generics: generics.into_tcx(tcx),
|
||||
|
@ -615,12 +615,12 @@ pub(crate) fn from_function(
|
|||
}
|
||||
|
||||
pub(crate) fn from_function_method(
|
||||
function: clean::Function,
|
||||
function: Box<clean::Function>,
|
||||
has_body: bool,
|
||||
header: rustc_hir::FnHeader,
|
||||
tcx: TyCtxt<'_>,
|
||||
) -> Method {
|
||||
let clean::Function { decl, generics } = function;
|
||||
let clean::Function { decl, generics } = *function;
|
||||
Method {
|
||||
decl: decl.into_tcx(tcx),
|
||||
generics: generics.into_tcx(tcx),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue