about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTor Hovland <tor+github@hovland.co>2021-04-18 17:30:04 +0200
committerTor Hovland <tor.hovland@bekk.no>2021-04-18 18:02:08 +0200
commitc975fe25e4b5756b03033e4819a5c5044ca353f2 (patch)
tree9386c531ea39473b7d785b60c10c64fb2f523d77
parente2a77b3d46e09a263fbba0ad7b964781659e6f40 (diff)
downloadrust-c975fe25e4b5756b03033e4819a5c5044ca353f2.tar.gz
rust-c975fe25e4b5756b03033e4819a5c5044ca353f2.zip
Put attrs in a Box for memory efficiency.
-rw-r--r--src/librustdoc/clean/types.rs2
-rw-r--r--src/librustdoc/clean/utils.rs2
-rw-r--r--src/librustdoc/html/render/print_item.rs2
3 files changed, 2 insertions, 4 deletions
diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs
index 75c541a50ed..dc8784df931 100644
--- a/src/librustdoc/clean/types.rs
+++ b/src/librustdoc/clean/types.rs
@@ -2081,7 +2081,7 @@ crate enum ImportKind {
 crate struct ImportSource {
     crate path: Path,
     crate did: Option<DefId>,
-    crate attrs: Option<Attributes>,
+    crate attrs: Option<Box<Attributes>>,
 }
 
 #[derive(Clone, Debug)]
diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs
index 898a5b0df5d..97dad8924b6 100644
--- a/src/librustdoc/clean/utils.rs
+++ b/src/librustdoc/clean/utils.rs
@@ -469,7 +469,7 @@ crate fn register_res(cx: &mut DocContext<'_>, res: Res) -> DefId {
 
 crate fn resolve_use_source(cx: &mut DocContext<'_>, path: Path) -> ImportSource {
     let did = if path.res.opt_def_id().is_none() { None } else { Some(register_res(cx, path.res)) };
-    let attrs = did.map(|did| cx.tcx.get_attrs(did).clean(cx));
+    let attrs = did.map(|did| Box::new(cx.tcx.get_attrs(did).clean(cx)));
 
     ImportSource { did, path, attrs }
 }
diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs
index 045ff5b4b89..d941095e5e1 100644
--- a/src/librustdoc/html/render/print_item.rs
+++ b/src/librustdoc/html/render/print_item.rs
@@ -285,8 +285,6 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl
                 let (stab, stab_tags) = if let (Some(def_id), Some(attrs)) =
                     (import.source.did, import.source.attrs.clone())
                 {
-                    let attrs = Box::new(attrs);
-
                     // Just need an item with the correct def_id and attrs
                     let import_item = clean::Item { def_id, attrs, ..myitem.clone() };