From ef053fd6f0faa848097ff8b924ac859c667c8d15 Mon Sep 17 00:00:00 2001 From: Wesley Wiser Date: Thu, 20 May 2021 13:58:13 -0400 Subject: [PATCH] Change the type name from `_enum<..>` to `enum$<..>` This makes the type name inline with the proposed standard in #85269. --- .../src/debuginfo/metadata.rs | 6 +- .../src/debuginfo/type_names.rs | 4 +- src/etc/natvis/intrinsic.natvis | 4 +- src/test/debuginfo/msvc-pretty-enums.rs | 68 +++++++++---------- src/test/debuginfo/pretty-std.rs | 6 +- 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs index 1d81d880b8d..f56dace0d33 100644 --- a/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs +++ b/compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs @@ -1537,7 +1537,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { // For MSVC, we generate a union of structs for each variant with an explicit // discriminant field roughly equivalent to the following C: // ```c - // union _enum<{name}> { + // union enum$<{name}> { // struct {variant 0 name} { // tag$ variant$; // @@ -1628,7 +1628,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { // make the discriminant field that type. We then use natvis to render the enum type correctly in Windbg/VS. // This will generate debuginfo roughly equivalent to the following C: // ```c - // union _enum<{name}, {min niche}, {max niche}, {dataful variant name} { + // union enum$<{name}, {min niche}, {max niche}, {dataful variant name} { // struct dataful_variant { // // }, @@ -1639,7 +1639,7 @@ impl EnumMemberDescriptionFactory<'ll, 'tcx> { // } // } // ``` - // The natvis in `intrinsic.natvis` matches on the type name `_enum<*, *, *, *>` + // The natvis in `intrinsic.natvis` matches on the type name `enum$<*, *, *, *>` // and evaluates `this.discriminant$.discriminant`. If the value is between // the min niche and max niche, then the enum is in the dataful variant and // `this.dataful_variant` is rendered. Otherwise, the enum is in one of the diff --git a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs index 1f3e9493318..0f8dc06f4ca 100644 --- a/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs +++ b/compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs @@ -267,7 +267,7 @@ pub fn push_debuginfo_type_name<'tcx>( let max = dataful_discriminant_range.end(); let max = tag.value.size(&tcx).truncate(*max); - output.push_str("_enum<"); + output.push_str("enum$<"); push_item_name(tcx, def.did, true, output); push_type_params(tcx, substs, output, visited); @@ -275,7 +275,7 @@ pub fn push_debuginfo_type_name<'tcx>( output.push_str(&format!(", {}, {}, {}>", min, max, dataful_variant_name)); } else { - output.push_str("_enum<"); + output.push_str("enum$<"); push_item_name(tcx, def.did, true, output); push_type_params(tcx, substs, output, visited); output.push('>'); diff --git a/src/etc/natvis/intrinsic.natvis b/src/etc/natvis/intrinsic.natvis index 82d3ab15a70..09b5c9f091d 100644 --- a/src/etc/natvis/intrinsic.natvis +++ b/src/etc/natvis/intrinsic.natvis @@ -149,7 +149,7 @@ ... - + {tag(),en} {tag(),en} @@ -189,7 +189,7 @@ - + {"$T4",sb}({dataful_variant}) diff --git a/src/test/debuginfo/msvc-pretty-enums.rs b/src/test/debuginfo/msvc-pretty-enums.rs index ad1b45a7bc2..e2a331ca17a 100644 --- a/src/test/debuginfo/msvc-pretty-enums.rs +++ b/src/test/debuginfo/msvc-pretty-enums.rs @@ -8,72 +8,72 @@ // so the best we can do is to make sure we are generating the right debuginfo // cdb-command: dx -r2 a,! -// cdb-check:a,! [Type: _enum>, 2, 16, Some>] -// cdb-check: [+0x000] dataful_variant [Type: _enum>, 2, 16, Some>::Some] +// cdb-check:a,! [Type: enum$>, 2, 16, Some>] +// cdb-check: [+0x000] dataful_variant [Type: enum$>, 2, 16, Some>::Some] // cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum] -// cdb-check: [+0x000] discriminant$ [Type: _enum>, 2, 16, Some>::discriminant$] -// cdb-check: [+0x000] discriminant : 0x2 [Type: _enum>, 2, 16, Some>::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$>, 2, 16, Some>::discriminant$] +// cdb-check: [+0x000] discriminant : 0x2 [Type: enum$>, 2, 16, Some>::tag$] // cdb-command: dx -r2 b,! -// cdb-check:b,! [Type: _enum>, 2, 16, Some>] -// cdb-check: [+0x000] dataful_variant [Type: _enum>, 2, 16, Some>::Some] +// cdb-check:b,! [Type: enum$>, 2, 16, Some>] +// cdb-check: [+0x000] dataful_variant [Type: enum$>, 2, 16, Some>::Some] // cdb-check: [+0x000] __0 : 0x11 [Type: msvc_pretty_enums::CStyleEnum] -// cdb-check: [+0x000] discriminant$ [Type: _enum>, 2, 16, Some>::discriminant$] -// cdb-check: [+0x000] discriminant : None (0x11) [Type: _enum>, 2, 16, Some>::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$>, 2, 16, Some>::discriminant$] +// cdb-check: [+0x000] discriminant : None (0x11) [Type: enum$>, 2, 16, Some>::tag$] // cdb-command: dx -r2 c,! -// cdb-check:c,! [Type: _enum] -// cdb-check: [+0x000] dataful_variant [Type: _enum::Data] +// cdb-check:c,! [Type: enum$] +// cdb-check: [+0x000] dataful_variant [Type: enum$::Data] // cdb-check: [+0x000] my_data : 0x11 [Type: msvc_pretty_enums::CStyleEnum] -// cdb-check: [+0x000] discriminant$ [Type: _enum::discriminant$] -// cdb-check: [+0x000] discriminant : Tag1 (0x11) [Type: _enum::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$::discriminant$] +// cdb-check: [+0x000] discriminant : Tag1 (0x11) [Type: enum$::tag$] // cdb-command: dx -r2 d,! -// cdb-check:d,! [Type: _enum] -// cdb-check: [+0x000] dataful_variant [Type: _enum::Data] +// cdb-check:d,! [Type: enum$] +// cdb-check: [+0x000] dataful_variant [Type: enum$::Data] // cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] -// cdb-check: [+0x000] discriminant$ [Type: _enum::discriminant$] -// cdb-check: [+0x000] discriminant : 0x10 [Type: _enum::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$::discriminant$] +// cdb-check: [+0x000] discriminant : 0x10 [Type: enum$::tag$] // cdb-command: dx -r2 e,! -// cdb-check:e,! [Type: _enum] -// cdb-check: [+0x000] dataful_variant [Type: _enum::Data] +// cdb-check:e,! [Type: enum$] +// cdb-check: [+0x000] dataful_variant [Type: enum$::Data] // cdb-check: [+0x000] my_data : 0x13 [Type: msvc_pretty_enums::CStyleEnum] -// cdb-check: [+0x000] discriminant$ [Type: _enum::discriminant$] -// cdb-check: [+0x000] discriminant : Tag2 (0x13) [Type: _enum::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$::discriminant$] +// cdb-check: [+0x000] discriminant : Tag2 (0x13) [Type: enum$::tag$] // cdb-command: dx -r2 f,! -// cdb-check:f,! [Type: _enum, 1, [...], Some>] -// cdb-check: [+0x000] dataful_variant [Type: _enum, 1, [...], Some>::Some] +// cdb-check:f,! [Type: enum$, 1, [...], Some>] +// cdb-check: [+0x000] dataful_variant [Type: enum$, 1, [...], Some>::Some] // cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *] -// cdb-check: [+0x000] discriminant$ [Type: _enum, 1, [...], Some>::discriminant$] -// cdb-check: [+0x000] discriminant : 0x[...] [Type: _enum, 1, [...], Some>::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$, 1, [...], Some>::discriminant$] +// cdb-check: [+0x000] discriminant : 0x[...] [Type: enum$, 1, [...], Some>::tag$] // cdb-command: dx -r2 g,! -// cdb-check:g,! [Type: _enum, 1, [...], Some>] -// cdb-check: [+0x000] dataful_variant [Type: _enum, 1, [...], Some>::Some] +// cdb-check:g,! [Type: enum$, 1, [...], Some>] +// cdb-check: [+0x000] dataful_variant [Type: enum$, 1, [...], Some>::Some] // cdb-check: [+0x000] __0 : 0x0 [Type: unsigned int *] -// cdb-check: [+0x000] discriminant$ [Type: _enum, 1, [...], Some>::discriminant$] -// cdb-check: [+0x000] discriminant : None (0x0) [Type: _enum, 1, [...], Some>::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$, 1, [...], Some>::discriminant$] +// cdb-check: [+0x000] discriminant : None (0x0) [Type: enum$, 1, [...], Some>::tag$] // cdb-command: dx h -// cdb-check:h : Some [Type: _enum>] +// cdb-check:h : Some [Type: enum$>] // cdb-check: [+0x000] variant$ : Some (0x1) [Type: core::option::Option] // cdb-check: [+0x004] __0 : 0xc [Type: unsigned int] // cdb-command: dx i -// cdb-check:i : None [Type: _enum>] +// cdb-check:i : None [Type: enum$>] // cdb-check: [+0x000] variant$ : None (0x0) [Type: core::option::Option] // cdb-command: dx j // cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum] // cdb-command: dx -r2 k,! -// cdb-check:k,! [Type: _enum, 1, [...], Some>] -// cdb-check: [+0x000] dataful_variant [Type: _enum, 1, [...], Some>::Some] +// cdb-check:k,! [Type: enum$, 1, [...], Some>] +// cdb-check: [+0x000] dataful_variant [Type: enum$, 1, [...], Some>::Some] // cdb-check: [+0x000] __0 [Type: alloc::string::String] -// cdb-check: [+0x000] discriminant$ [Type: _enum, 1, [...], Some>::discriminant$] -// cdb-check: [+0x000] discriminant : 0x[...] [Type: _enum, 1, [...], Some>::tag$] +// cdb-check: [+0x000] discriminant$ [Type: enum$, 1, [...], Some>::discriminant$] +// cdb-check: [+0x000] discriminant : 0x[...] [Type: enum$, 1, [...], Some>::tag$] pub enum CStyleEnum { Low = 2, diff --git a/src/test/debuginfo/pretty-std.rs b/src/test/debuginfo/pretty-std.rs index e9f690fac2e..68e73b5f38d 100644 --- a/src/test/debuginfo/pretty-std.rs +++ b/src/test/debuginfo/pretty-std.rs @@ -112,11 +112,11 @@ // NOTE: OsString doesn't have a .natvis entry yet. // cdb-command: dx some -// cdb-check:some : Some [Type: _enum>] +// cdb-check:some : Some [Type: enum$>] // cdb-command: dx none -// cdb-check:none : None [Type: _enum>] +// cdb-check:none : None [Type: enum$>] // cdb-command: dx some_string -// cdb-check:some_string [Type: _enum, 1, [...], Some>] +// cdb-check:some_string [Type: enum$, 1, [...], Some>] #![allow(unused_variables)] use std::ffi::OsString;