diff options
| author | Wesley Wiser <wesleywiser@microsoft.com> | 2021-06-25 13:33:00 -0400 |
|---|---|---|
| committer | Wesley Wiser <wesleywiser@microsoft.com> | 2021-07-02 20:16:37 -0400 |
| commit | d94f087848ee05036769bd4dc78337ab3604a776 (patch) | |
| tree | edaa85b82e408ccead0f5c21696d18f388f85d48 /compiler/rustc_codegen_ssa/src/debuginfo | |
| parent | f24355896ba0986e4d27eff45084f704ec7e7948 (diff) | |
| download | rust-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/debuginfo')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs | 11 |
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); } } |
