From 5f84f4bdc92caca64ed58509abe3c313f3c3454a Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sat, 30 Mar 2024 12:57:10 -0700 Subject: [PATCH 1/5] rustdoc: clean up type alias code --- src/librustdoc/html/render/print_item.rs | 28 ++++++++++-------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index fbb521a6188ae..befb27f9320d3 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -1237,22 +1237,18 @@ fn item_opaque_ty( } fn item_type_alias(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean::TypeAlias) { - fn write_content(w: &mut Buffer, cx: &Context<'_>, it: &clean::Item, t: &clean::TypeAlias) { - wrap_item(w, |w| { - write!( - w, - "{attrs}{vis}type {name}{generics}{where_clause} = {type_};", - attrs = render_attributes_in_pre(it, "", cx), - vis = visibility_print_with_space(it, cx), - name = it.name.unwrap(), - generics = t.generics.print(cx), - where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline), - type_ = t.type_.print(cx), - ); - }); - } - - write_content(w, cx, it, t); + wrap_item(w, |w| { + write!( + w, + "{attrs}{vis}type {name}{generics}{where_clause} = {type_};", + attrs = render_attributes_in_pre(it, "", cx), + vis = visibility_print_with_space(it, cx), + name = it.name.unwrap(), + generics = t.generics.print(cx), + where_clause = print_where_clause(&t.generics, cx, 0, Ending::Newline), + type_ = t.type_.print(cx), + ); + }); write!(w, "{}", document(cx, it, None, HeadingOffset::H2)); From dac788f0a1488f52503b016f214710c390b08d0e Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 9 Apr 2024 15:07:43 -0700 Subject: [PATCH 2/5] rustdoc: reduce size of `` with preload loop --- src/librustdoc/html/templates/page.html | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html index 0f3debae66c77..c8c656b48b13e 100644 --- a/src/librustdoc/html/templates/page.html +++ b/src/librustdoc/html/templates/page.html @@ -6,13 +6,10 @@ {# #} {# #} {{page.title}} {# #} - {# #} + {# #} {# #} {# #}
{{+ display_krate_version_extra}}
{# #} {% endif %} {% else %} -
+
{# #}

Files

{# #}
{# #} {% endif %} {{ sidebar|safe }} {# #} - + {# #}
{# #} {% if page.css_class != "src" %}
{% endif %}
{# #} {# #} {# #} diff --git a/src/librustdoc/html/templates/print_item.html b/src/librustdoc/html/templates/print_item.html index 1d215c26968d8..76e770453b6ea 100644 --- a/src/librustdoc/html/templates/print_item.html +++ b/src/librustdoc/html/templates/print_item.html @@ -7,9 +7,7 @@

{% endfor %} {{name}} {# #} {# #}

{# #} diff --git a/src/librustdoc/html/templates/sidebar.html b/src/librustdoc/html/templates/sidebar.html index d982134181c52..3251b4c14c95a 100644 --- a/src/librustdoc/html/templates/sidebar.html +++ b/src/librustdoc/html/templates/sidebar.html @@ -5,7 +5,7 @@

{# #} {% endif %}