Skip to content

Commit

Permalink
Box Typedef to reduce the size of ItemKind
Browse files Browse the repository at this point in the history
  • Loading branch information
jyn514 committed Dec 13, 2020
1 parent 0b82a25 commit 32b2b42
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@ impl Clean<Item> for ty::AssocItem {
let type_ = cx.tcx.type_of(self.def_id).clean(cx);
let item_type = type_.def_id().and_then(|did| inline::build_ty(cx, did));
TypedefItem(
Typedef {
box Typedef {
type_,
generics: Generics { params: Vec::new(), where_predicates: Vec::new() },
item_type,
Expand Down Expand Up @@ -1981,7 +1981,7 @@ impl Clean<Vec<Item>> for (&hir::Item<'_>, Option<Symbol>) {
let rustdoc_ty = ty.clean(cx);
let item_type = rustdoc_ty.def_id().and_then(|did| inline::build_ty(cx, did));
TypedefItem(
Typedef { type_: rustdoc_ty, generics: generics.clean(cx), item_type },
box Typedef { type_: rustdoc_ty, generics: generics.clean(cx), item_type },
false,
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ crate enum ItemKind {
EnumItem(Enum),
FunctionItem(Box<Function>),
ModuleItem(Module),
TypedefItem(Typedef, bool /* is associated type */),
TypedefItem(Box<Typedef>, bool /* is associated type */),
OpaqueTyItem(OpaqueTy),
StaticItem(Static),
ConstantItem(Constant),
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3559,7 +3559,7 @@ fn render_deref_methods(
.items
.iter()
.find_map(|item| match item.kind {
clean::TypedefItem(ref t, true) => Some(match *t {
clean::TypedefItem(ref t, true) => Some(match **t {
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
_ => (&t.type_, &t.type_),
}),
Expand Down Expand Up @@ -4237,7 +4237,7 @@ fn sidebar_assoc_items(it: &clean::Item) -> String {
{
if let Some((target, real_target)) =
impl_.inner_impl().items.iter().find_map(|item| match item.kind {
clean::TypedefItem(ref t, true) => Some(match *t {
clean::TypedefItem(ref t, true) => Some(match **t {
clean::Typedef { item_type: Some(ref type_), .. } => (type_, &t.type_),
_ => (&t.type_, &t.type_),
}),
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/json/conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl From<clean::ItemKind> for ItemEnum {
StaticItem(s) => ItemEnum::StaticItem(s.into()),
ForeignStaticItem(s) => ItemEnum::StaticItem(s.into()),
ForeignTypeItem => ItemEnum::ForeignTypeItem,
TypedefItem(t, _) => ItemEnum::TypedefItem(t.into()),
TypedefItem(box t, _) => ItemEnum::TypedefItem(t.into()),
OpaqueTyItem(t) => ItemEnum::OpaqueTyItem(t.into()),
ConstantItem(c) => ItemEnum::ConstantItem(c.into()),
MacroItem(m) => ItemEnum::MacroItem(m.source),
Expand Down

0 comments on commit 32b2b42

Please sign in to comment.