From d94f087848ee05036769bd4dc78337ab3604a776 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Fri, 25 Jun 2021 13:33:00 -0400 Subject: 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` then it could be very confusing which variant was the active one. --- compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'compiler/rustc_codegen_ssa') 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); } } -- cgit 1.4.1-3-g733a5