diff options
| author | Justus K <justus.k@protonmail.com> | 2021-06-27 09:28:17 +0200 |
|---|---|---|
| committer | Justus K <justus.k@protonmail.com> | 2021-07-05 19:51:54 +0200 |
| commit | 97c82d8731784866dfc12f7e79e592a9e191c28f (patch) | |
| tree | 0de173bd65a2c63a30e7829191fee5d26a2d8d2e /src/librustdoc/html/render | |
| parent | 45d3daece364e4cf6b6bc4668dcfd7670197b1e8 (diff) | |
| download | rust-97c82d8731784866dfc12f7e79e592a9e191c28f.tar.gz rust-97c82d8731784866dfc12f7e79e592a9e191c28f.zip | |
Revert "rustdoc: Store DefId's in ItemId on heap for decreasing Item's size"
This reverts commit 41a345d4c46dad1a98c9993bc78513415994e8ba.
Diffstat (limited to 'src/librustdoc/html/render')
| -rw-r--r-- | src/librustdoc/html/render/mod.rs | 21 | ||||
| -rw-r--r-- | src/librustdoc/html/render/print_item.rs | 36 |
2 files changed, 24 insertions, 33 deletions
diff --git a/src/librustdoc/html/render/mod.rs b/src/librustdoc/html/render/mod.rs index 1cee68baff4..97ee682c11c 100644 --- a/src/librustdoc/html/render/mod.rs +++ b/src/librustdoc/html/render/mod.rs @@ -753,7 +753,7 @@ fn assoc_const( w, "{}{}const <a href=\"{}\" class=\"constant\"><b>{}</b></a>: {}", extra, - it.visibility.print_with_space(it.def_id.clone(), cx), + it.visibility.print_with_space(it.def_id, cx), naive_assoc_href(it, link, cx), it.name.as_ref().unwrap(), ty.print(cx) @@ -872,7 +872,7 @@ fn render_assoc_item( .unwrap_or_else(|| format!("#{}.{}", ty, name)) } }; - let vis = meth.visibility.print_with_space(meth.def_id.clone(), cx).to_string(); + let vis = meth.visibility.print_with_space(meth.def_id, cx).to_string(); let constness = print_constness_with_space(&header.constness, meth.const_stability(cx.tcx())); let asyncness = header.asyncness.print_with_space(); @@ -984,7 +984,7 @@ fn render_attributes_in_code(w: &mut Buffer, it: &clean::Item) { } } -#[derive(Clone)] +#[derive(Copy, Clone)] enum AssocItemLink<'a> { Anchor(Option<&'a str>), GotoSource(ItemId, &'a FxHashSet<Symbol>), @@ -994,7 +994,7 @@ impl<'a> AssocItemLink<'a> { fn anchor(&self, id: &'a str) -> Self { match *self { AssocItemLink::Anchor(_) => AssocItemLink::Anchor(Some(&id)), - ref other => other.clone(), + ref other => *other, } } } @@ -1306,14 +1306,7 @@ fn render_impl( } else { // In case the item isn't documented, // provide short documentation from the trait. - document_short( - &mut doc_buffer, - it, - cx, - link.clone(), - parent, - show_def_docs, - ); + document_short(&mut doc_buffer, it, cx, link, parent, show_def_docs); } } } else { @@ -1324,7 +1317,7 @@ fn render_impl( } } } else { - document_short(&mut doc_buffer, item, cx, link.clone(), parent, show_def_docs); + document_short(&mut doc_buffer, item, cx, link, parent, show_def_docs); } } let w = if short_documented && trait_.is_some() { interesting } else { boring }; @@ -1452,7 +1445,7 @@ fn render_impl( trait_item, if trait_.is_some() { &i.impl_item } else { parent }, parent, - link.clone(), + link, render_mode, false, trait_.map(|t| &t.trait_), diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 70e80b20b2a..eeac9d1a9db 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -245,7 +245,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl // (which is the position in the vector). indices.dedup_by_key(|i| { ( - items[*i].def_id.clone(), + items[*i].def_id, if items[*i].name.as_ref().is_some() { Some(full_path(cx, &items[*i])) } else { None }, items[*i].type_(), if items[*i].is_import() { *i } else { 0 }, @@ -288,14 +288,14 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl Some(ref src) => write!( w, "<div class=\"item-left\"><code>{}extern crate {} as {};", - myitem.visibility.print_with_space(myitem.def_id.clone(), cx), + myitem.visibility.print_with_space(myitem.def_id, cx), anchor(myitem.def_id.expect_def_id(), &*src.as_str(), cx), myitem.name.as_ref().unwrap(), ), None => write!( w, "<div class=\"item-left\"><code>{}extern crate {};", - myitem.visibility.print_with_space(myitem.def_id.clone(), cx), + myitem.visibility.print_with_space(myitem.def_id, cx), anchor( myitem.def_id.expect_def_id(), &*myitem.name.as_ref().unwrap().as_str(), @@ -336,7 +336,7 @@ fn item_module(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item, items: &[cl <div class=\"item-right docblock-short\">{stab_tags}</div>", stab = stab.unwrap_or_default(), add = add, - vis = myitem.visibility.print_with_space(myitem.def_id.clone(), cx), + vis = myitem.visibility.print_with_space(myitem.def_id, cx), imp = import.print(cx), stab_tags = stab_tags.unwrap_or_default(), ); @@ -437,7 +437,7 @@ fn extra_info_tags(item: &clean::Item, parent: &clean::Item, tcx: TyCtxt<'_>) -> } fn item_function(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, f: &clean::Function) { - let vis = it.visibility.print_with_space(it.def_id.clone(), cx).to_string(); + let vis = it.visibility.print_with_space(it.def_id, cx).to_string(); let constness = print_constness_with_space(&f.header.constness, it.const_stability(cx.tcx())); let asyncness = f.header.asyncness.print_with_space(); let unsafety = f.header.unsafety.print_with_space(); @@ -489,7 +489,7 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra write!( w, "{}{}{}trait {}{}{}", - it.visibility.print_with_space(it.def_id.clone(), cx), + it.visibility.print_with_space(it.def_id, cx), t.unsafety.print_with_space(), if t.is_auto { "auto " } else { "" }, it.name.as_ref().unwrap(), @@ -710,10 +710,8 @@ fn item_trait(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::Tra for implementor in foreign { let provided_methods = implementor.inner_impl().provided_trait_methods(cx.tcx()); - let assoc_link = AssocItemLink::GotoSource( - implementor.impl_item.def_id.clone(), - &provided_methods, - ); + let assoc_link = + AssocItemLink::GotoSource(implementor.impl_item.def_id, &provided_methods); render_impl( w, cx, @@ -917,7 +915,7 @@ fn item_enum(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, e: &clean::Enum write!( w, "{}enum {}{}{}", - it.visibility.print_with_space(it.def_id.clone(), cx), + it.visibility.print_with_space(it.def_id, cx), it.name.as_ref().unwrap(), e.generics.print(cx), print_where_clause(&e.generics, cx, 0, true), @@ -1105,7 +1103,7 @@ fn item_constant(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, c: &clean:: write!( w, "{vis}const {name}: {typ}", - vis = it.visibility.print_with_space(it.def_id.clone(), cx), + vis = it.visibility.print_with_space(it.def_id, cx), name = it.name.as_ref().unwrap(), typ = c.type_.print(cx), ); @@ -1195,7 +1193,7 @@ fn item_static(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, s: &clean::St write!( w, "{vis}static {mutability}{name}: {typ}</pre>", - vis = it.visibility.print_with_space(it.def_id.clone(), cx), + vis = it.visibility.print_with_space(it.def_id, cx), mutability = s.mutability.print_with_space(), name = it.name.as_ref().unwrap(), typ = s.type_.print(cx) @@ -1209,7 +1207,7 @@ fn item_foreign_type(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item) { write!( w, " {}type {};\n}}</pre>", - it.visibility.print_with_space(it.def_id.clone(), cx), + it.visibility.print_with_space(it.def_id, cx), it.name.as_ref().unwrap(), ); @@ -1364,7 +1362,7 @@ fn render_union( write!( w, "{}{}{}", - it.visibility.print_with_space(it.def_id.clone(), cx), + it.visibility.print_with_space(it.def_id, cx), if structhead { "union " } else { "" }, it.name.as_ref().unwrap() ); @@ -1386,7 +1384,7 @@ fn render_union( write!( w, " {}{}: {},\n{}", - field.visibility.print_with_space(field.def_id.clone(), cx), + field.visibility.print_with_space(field.def_id, cx), field.name.as_ref().unwrap(), ty.print(cx), tab @@ -1416,7 +1414,7 @@ fn render_struct( write!( w, "{}{}{}", - it.visibility.print_with_space(it.def_id.clone(), cx), + it.visibility.print_with_space(it.def_id, cx), if structhead { "struct " } else { "" }, it.name.as_ref().unwrap() ); @@ -1442,7 +1440,7 @@ fn render_struct( w, "\n{} {}{}: {},", tab, - field.visibility.print_with_space(field.def_id.clone(), cx), + field.visibility.print_with_space(field.def_id, cx), field.name.as_ref().unwrap(), ty.print(cx), ); @@ -1476,7 +1474,7 @@ fn render_struct( write!( w, "{}{}", - field.visibility.print_with_space(field.def_id.clone(), cx), + field.visibility.print_with_space(field.def_id, cx), ty.print(cx), ) } |
