about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorWesley Wiser <wesleywiser@microsoft.com>2021-06-25 13:33:00 -0400
committerWesley Wiser <wesleywiser@microsoft.com>2021-07-02 20:16:37 -0400
commitd94f087848ee05036769bd4dc78337ab3604a776 (patch)
treeedaa85b82e408ccead0f5c21696d18f388f85d48 /compiler/rustc_codegen_ssa/src
parentf24355896ba0986e4d27eff45084f704ec7e7948 (diff)
downloadrust-d94f087848ee05036769bd4dc78337ab3604a776.tar.gz
rust-d94f087848ee05036769bd4dc78337ab3604a776.zip
Show the variant name for univariant enums
Previously, only the fields would be displayed with no indication of the
variant name. If you already knew the enum was univariant, this was ok
but if the enum was univariant because of layout, for example, a
`Result<T, !>` then it could be very confusing which variant was the
active one.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
index a97c6a6b442..e3348c6bf08 100644
--- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
+++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
@@ -397,6 +397,17 @@ pub fn push_debuginfo_type_name<'tcx>(
             output.push_str("enum$<");
             push_item_name(tcx, def.did, true, output);
             push_generic_params_internal(tcx, substs, output, visited);
+
+            if let Variants::Single { index: variant_idx } = &layout.variants {
+                // Uninhabited enums can't be constructed and should never need to be visualized so
+                // skip this step for them.
+                if def.variants.len() != 0 {
+                    let variant = def.variants[*variant_idx].ident.as_str();
+
+                    output.push_str(&format!(", {}", variant));
+                }
+            }
+
             push_close_angle_bracket(tcx, output);
         }
     }