Skip to content

Commit c7b0ddb

Browse files
committed
Auto merge of rust-lang#80802 - jyn514:box-attributes, r=nnethercote
Box Item::Attributes This reduces the size of Item from 128 to 40 bytes. I think this is as small as it needs to get 🎉 Builds on rust-lang#80339 and should not be merged before. r? `@GuillaumeGomez`
2 parents 180fdff + 690aeaf commit c7b0ddb

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/librustdoc/clean/inline.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ crate fn try_inline(
121121
};
122122

123123
let target_attrs = load_attrs(cx, did);
124-
let attrs = merge_attrs(cx, Some(parent_module), target_attrs, attrs_clone);
124+
let attrs = box merge_attrs(cx, Some(parent_module), target_attrs, attrs_clone);
125125

126126
cx.renderinfo.borrow_mut().inlined.insert(did);
127127
let what_rustc_thinks = clean::Item::from_def_id_and_parts(did, Some(name), kind, cx);
@@ -446,7 +446,7 @@ crate fn build_impl(
446446
}),
447447
cx,
448448
);
449-
item.attrs = merge_attrs(cx, parent_module.into(), load_attrs(cx, did), attrs);
449+
item.attrs = box merge_attrs(cx, parent_module.into(), load_attrs(cx, did), attrs);
450450
debug!("merged_attrs={:?}", item.attrs);
451451
ret.push(item);
452452
}
@@ -468,7 +468,7 @@ fn build_module(cx: &DocContext<'_>, did: DefId, visited: &mut FxHashSet<DefId>)
468468
// Primitive types can't be inlined so generate an import instead.
469469
items.push(clean::Item {
470470
name: None,
471-
attrs: clean::Attributes::default(),
471+
attrs: box clean::Attributes::default(),
472472
source: clean::Span::dummy(),
473473
def_id: DefId::local(CRATE_DEF_INDEX),
474474
visibility: clean::Public,

src/librustdoc/clean/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2164,7 +2164,7 @@ fn clean_extern_crate(
21642164
// FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
21652165
vec![Item {
21662166
name: None,
2167-
attrs: krate.attrs.clean(cx),
2167+
attrs: box krate.attrs.clean(cx),
21682168
source: krate.span.clean(cx),
21692169
def_id: crate_def_id,
21702170
visibility: krate.vis.clean(cx),
@@ -2246,7 +2246,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22462246
) {
22472247
items.push(Item {
22482248
name: None,
2249-
attrs: self.attrs.clean(cx),
2249+
attrs: box self.attrs.clean(cx),
22502250
source: self.span.clean(cx),
22512251
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
22522252
visibility: self.vis.clean(cx),
@@ -2264,7 +2264,7 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
22642264

22652265
vec![Item {
22662266
name: None,
2267-
attrs: self.attrs.clean(cx),
2267+
attrs: box self.attrs.clean(cx),
22682268
source: self.span.clean(cx),
22692269
def_id: cx.tcx.hir().local_def_id(self.id).to_def_id(),
22702270
visibility: self.vis.clean(cx),

src/librustdoc/clean/types.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ crate struct Item {
8282
crate source: Span,
8383
/// Not everything has a name. E.g., impls
8484
crate name: Option<Symbol>,
85-
crate attrs: Attributes,
85+
crate attrs: Box<Attributes>,
8686
crate visibility: Visibility,
8787
crate kind: Box<ItemKind>,
8888
crate def_id: DefId,
8989
}
9090

9191
// `Item` is used a lot. Make sure it doesn't unintentionally get bigger.
9292
#[cfg(target_arch = "x86_64")]
93-
rustc_data_structures::static_assert_size!(Item, 136);
93+
rustc_data_structures::static_assert_size!(Item, 48);
9494

9595
impl fmt::Debug for Item {
9696
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
@@ -159,7 +159,7 @@ impl Item {
159159
kind: box kind,
160160
name,
161161
source: source.clean(cx),
162-
attrs: cx.tcx.get_attrs(def_id).clean(cx),
162+
attrs: box cx.tcx.get_attrs(def_id).clean(cx),
163163
visibility: cx.tcx.visibility(def_id).clean(cx),
164164
}
165165
}

0 commit comments

Comments
 (0)