about summary refs log tree commit diff
path: root/src/librustdoc
diff options
context:
space:
mode:
authorDylan DPC <99973273+Dylan-DPC@users.noreply.github.com>2023-05-04 00:17:27 +0530
committerGitHub <noreply@github.com>2023-05-04 00:17:27 +0530
commite87fcf979fc5ff36386c642d779f2c071cf30fe8 (patch)
tree10c28bb928677239f9ed65d2ef54785fe39bc51e /src/librustdoc
parent887dffc44795f30c32e8776a9a1850f82da81942 (diff)
parent7bc6d598f94744751a249ed18885592a6f077bcd (diff)
downloadrust-e87fcf979fc5ff36386c642d779f2c071cf30fe8.tar.gz
rust-e87fcf979fc5ff36386c642d779f2c071cf30fe8.zip
Rollup merge of #111097 - oli-obk:🚲_layout, r=compiler-errors
Avoid ICEing miri on layout query cycles

Miri has special logic for catching panics during interpretation. Raising a fatal error in rustc uses unwinding to abort compilation. Thus miri ends up catching that fatal error and thinks it saw an ICE. While we should probably change that to ignore `Fatal` payloads, I think it's also neat to continue compilation after a layout query cycle 😆

Query cycles now (in addition to reporting an error just like before), return `Err(Cycle)` instead of raising a fatal error. This allows the interpreter to wind down via the regular error paths.

r? `@RalfJung` for a first round, feel free to reroll for the compiler team once the miri side looks good
Diffstat (limited to 'src/librustdoc')
-rw-r--r--src/librustdoc/html/templates/type_layout.html93
1 files changed, 49 insertions, 44 deletions
diff --git a/src/librustdoc/html/templates/type_layout.html b/src/librustdoc/html/templates/type_layout.html
index 58b220c7428..20e09a54805 100644
--- a/src/librustdoc/html/templates/type_layout.html
+++ b/src/librustdoc/html/templates/type_layout.html
@@ -1,53 +1,58 @@
-<h2 id="layout" class="small-section-header">  {# #}
+<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 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> {# #}
+        <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. #}
+        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> {# #}
+        <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> {# #}
-    {% endmatch %}
+        <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> {# #}