From 3a72ea05a063453eeed10f0aa942c4bc669019d5 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Thu, 7 Jul 2022 17:22:04 +0200 Subject: [PATCH] [debuginfo] Add more test cases cpp-like enum debuginfo. --- src/test/debuginfo/msvc-pretty-enums.rs | 43 ++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/test/debuginfo/msvc-pretty-enums.rs b/src/test/debuginfo/msvc-pretty-enums.rs index 10b16c2f8978..03fc96cd53dd 100644 --- a/src/test/debuginfo/msvc-pretty-enums.rs +++ b/src/test/debuginfo/msvc-pretty-enums.rs @@ -55,15 +55,23 @@ // cdb-command: dx wrapping_niche128_dataful // cdb-check: wrapping_niche128_dataful : X [Type: enum2$] -// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128] +// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] // cdb-command: dx wrapping_niche128_none1 // cdb-check: wrapping_niche128_none1 : Y [Type: enum2$] -// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128] +// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] // cdb-command: dx wrapping_niche128_none2 // cdb-check: wrapping_niche128_none2 : Z [Type: enum2$] -// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128] +// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128] + +// cdb-command: dx direct_tag_128_a,d +// cdb-check: direct_tag_128_a,d : A [Type: enum2$] +// cdb-check: [+0x[...]] __0 : 42 [Type: unsigned int] + +// cdb-command: dx direct_tag_128_b,d +// cdb-check: direct_tag_128_b,d : B [Type: enum2$] +// cdb-check: [+0x[...]] __0 : 137 [Type: unsigned int] // cdb-command: dx niche_w_fields_1_some,d // cdb-check: niche_w_fields_1_some,d : A [Type: enum2$] @@ -76,7 +84,6 @@ // cdb-command: dx niche_w_fields_2_some,d // cdb-check: niche_w_fields_2_some,d : A [Type: enum2$] -// cdb-check: [] [Type: enum2$] // cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZeroU32] // cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64] @@ -118,7 +125,17 @@ // cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum2$,alloc::alloc::Global>,u64> >] // cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64] +// cdb-command: dx -r2 arbitrary_discr1,d +// cdb-check: arbitrary_discr1,d : Abc [Type: enum2$] +// cdb-check: [+0x[...]] __0 : 1234 [Type: unsigned int] + +// cdb-command: dx -r2 arbitrary_discr2,d +// cdb-check: arbitrary_discr2,d : Def [Type: enum2$] +// cdb-check: [+0x[...]] __0 : 5678 [Type: unsigned int] + #![feature(rustc_attrs)] +#![feature(repr128)] +#![feature(arbitrary_enum_discriminant)] use std::num::{NonZeroI128, NonZeroU32}; @@ -168,6 +185,18 @@ enum Wrapping128Niche { Z, } +#[repr(i128)] +enum DirectTag128 { + A(u32), + B(u32), +} + +#[repr(u32)] +enum ArbitraryDiscr { + Abc(u32) = 1000, + Def(u32) = 5000_000, +} + fn main() { let a = Some(CStyleEnum::Low); let b = Option::::None; @@ -189,6 +218,9 @@ fn main() { let wrapping_niche128_none1 = Wrapping128Niche::Y; let wrapping_niche128_none2 = Wrapping128Niche::Z; + let direct_tag_128_a = DirectTag128::A(42); + let direct_tag_128_b = DirectTag128::B(137); + let niche_w_fields_1_some = NicheLayoutWithFields1::A(&77, 7); let niche_w_fields_1_none = NicheLayoutWithFields1::B(99); @@ -205,6 +237,9 @@ fn main() { let niche_w_fields_std_result_ok: Result, u64> = Ok(vec![1, 2, 3].into()); let niche_w_fields_std_result_err: Result, u64> = Err(789); + let arbitrary_discr1 = ArbitraryDiscr::Abc(1234); + let arbitrary_discr2 = ArbitraryDiscr::Def(5678); + zzz(); // #break }