summaryrefslogtreecommitdiffstats
path: root/src/librustdoc/html/templates
diff options
context:
space:
mode:
Diffstat (limited to 'src/librustdoc/html/templates')
-rw-r--r--src/librustdoc/html/templates/item_union.html8
-rw-r--r--src/librustdoc/html/templates/type_layout.html58
-rw-r--r--src/librustdoc/html/templates/type_layout_size.html12
3 files changed, 74 insertions, 4 deletions
diff --git a/src/librustdoc/html/templates/item_union.html b/src/librustdoc/html/templates/item_union.html
index a01457971..c21967005 100644
--- a/src/librustdoc/html/templates/item_union.html
+++ b/src/librustdoc/html/templates/item_union.html
@@ -1,8 +1,8 @@
<pre class="rust item-decl"><code>
- {{ self.render_attributes_in_pre() | safe }}
+ {{ self::item_template_render_attributes_in_pre(self.borrow()) | safe }}
{{ self.render_union() | safe }}
</code></pre>
-{{ self.document() | safe }}
+{{ self::item_template_document(self.borrow()) | safe }}
{% if self.fields_iter().peek().is_some() %}
<h2 id="fields" class="fields small-section-header">
Fields<a href="#fields" class="anchor">§</a>
@@ -19,5 +19,5 @@
{{ self.document_field(field) | safe }}
{% endfor %}
{% endif %}
-{{ self.render_assoc_items() | safe }}
-{{ self.document_type_layout() | safe }}
+{{ self::item_template_render_assoc_items(self.borrow()) | safe }}
+{{ self::item_template_document_type_layout(self.borrow()) | safe }}
diff --git a/src/librustdoc/html/templates/type_layout.html b/src/librustdoc/html/templates/type_layout.html
new file mode 100644
index 000000000..20e09a548
--- /dev/null
+++ b/src/librustdoc/html/templates/type_layout.html
@@ -0,0 +1,58 @@
+<h2 id="layout" class="small-section-header"> {# #}
+ Layout<a href="#layout" class="anchor">§</a> {# #}
+</h2> {# #}
+<div class="docblock"> {# #}
+ {% match type_layout_size %}
+ {% when Ok(type_layout_size) %}
+ <div class="warning"> {# #}
+ <p> {# #}
+ <strong>Note:</strong> Most layout information is <strong>completely {#+ #}
+ unstable</strong> and may even differ between compilations. {#+ #}
+ The only exception is types with certain <code>repr(...)</code> {#+ #}
+ attributes. Please see the Rust Reference’s {#+ #}
+ <a href="https://doc.rust-lang.org/reference/type-layout.html">“Type Layout”</a> {#+ #}
+ chapter for details on type layout guarantees. {# #}
+ </p> {# #}
+ </div> {# #}
+ <p><strong>Size:</strong> {{ type_layout_size|safe }}</p> {# #}
+ {% if !variants.is_empty() %}
+ <p> {# #}
+ <strong>Size for each variant:</strong> {# #}
+ </p> {# #}
+ <ul> {# #}
+ {% for (name, layout_size) in variants %}
+ <li> {# #}
+ <code>{{ name }}</code>: {#+ #}
+ {{ layout_size|safe }}
+ </li> {# #}
+ {% endfor %}
+ </ul> {# #}
+ {% endif %}
+ {# This kind of layout error can occur with valid code, e.g. if you try to
+ get the layout of a generic type such as `Vec<T>`. #}
+ {% when Err(LayoutError::Unknown(_)) %}
+ <p> {# #}
+ <strong>Note:</strong> Unable to compute type layout, {#+ #}
+ possibly due to this type having generic parameters. {#+ #}
+ Layout can only be computed for concrete, fully-instantiated types. {# #}
+ </p> {# #}
+ {# This kind of error probably can't happen with valid code, but we don't
+ want to panic and prevent the docs from building, so we just let the
+ user know that we couldn't compute the layout. #}
+ {% when Err(LayoutError::SizeOverflow(_)) %}
+ <p> {# #}
+ <strong>Note:</strong> Encountered an error during type layout; {#+ #}
+ the type was too big. {# #}
+ </p> {# #}
+ {% when Err(LayoutError::NormalizationFailure(_, _)) %}
+ <p> {# #}
+ <strong>Note:</strong> Encountered an error during type layout; {#+ #}
+ the type failed to be normalized. {# #}
+ </p> {# #}
+ {% when Err(LayoutError::Cycle) %}
+ <p> {# #}
+ <strong>Note:</strong> Encountered an error during type layout; {#+ #}
+ the type's layout depended on the type's layout itself. {# #}
+ </p> {# #}
+ {% endmatch %}
+</div> {# #}
diff --git a/src/librustdoc/html/templates/type_layout_size.html b/src/librustdoc/html/templates/type_layout_size.html
new file mode 100644
index 000000000..9c2b39edc
--- /dev/null
+++ b/src/librustdoc/html/templates/type_layout_size.html
@@ -0,0 +1,12 @@
+{% if is_unsized %}
+ (unsized)
+{% else %}
+ {% if size == 1 %}
+ 1 byte
+ {% else %}
+ {{ size +}} bytes
+ {% endif %}
+ {% if is_uninhabited %}
+ {# +#} (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)
+ {% endif %}
+{% endif %}