Skip to content

Commit 3a72ea0

Browse files
[debuginfo] Add more test cases cpp-like enum debuginfo.
1 parent 1bbda88 commit 3a72ea0

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

src/test/debuginfo/msvc-pretty-enums.rs

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,23 @@
5555

5656
// cdb-command: dx wrapping_niche128_dataful
5757
// cdb-check: wrapping_niche128_dataful : X [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
58-
// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128]
58+
// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128]
5959

6060
// cdb-command: dx wrapping_niche128_none1
6161
// cdb-check: wrapping_niche128_none1 : Y [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
62-
// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128]
62+
// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128]
6363

6464
// cdb-command: dx wrapping_niche128_none2
6565
// cdb-check: wrapping_niche128_none2 : Z [Type: enum2$<msvc_pretty_enums::Wrapping128Niche>]
66-
// cdb-check: [+0x000] __0 [Type: msvc_pretty_enums::Wrapping128]
66+
// cdb-check: [+0x[...]] __0 [Type: msvc_pretty_enums::Wrapping128]
67+
68+
// cdb-command: dx direct_tag_128_a,d
69+
// cdb-check: direct_tag_128_a,d : A [Type: enum2$<msvc_pretty_enums::DirectTag128>]
70+
// cdb-check: [+0x[...]] __0 : 42 [Type: unsigned int]
71+
72+
// cdb-command: dx direct_tag_128_b,d
73+
// cdb-check: direct_tag_128_b,d : B [Type: enum2$<msvc_pretty_enums::DirectTag128>]
74+
// cdb-check: [+0x[...]] __0 : 137 [Type: unsigned int]
6775

6876
// cdb-command: dx niche_w_fields_1_some,d
6977
// cdb-check: niche_w_fields_1_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields1>]
@@ -76,7 +84,6 @@
7684

7785
// cdb-command: dx niche_w_fields_2_some,d
7886
// cdb-check: niche_w_fields_2_some,d : A [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields2>]
79-
// cdb-check: [<Raw View>] [Type: enum2$<msvc_pretty_enums::NicheLayoutWithFields2>]
8087
// cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZeroU32]
8188
// cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64]
8289

@@ -118,7 +125,17 @@
118125
// cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum2$<core::result::Result<alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>,u64> >]
119126
// cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64]
120127

128+
// cdb-command: dx -r2 arbitrary_discr1,d
129+
// cdb-check: arbitrary_discr1,d : Abc [Type: enum2$<msvc_pretty_enums::ArbitraryDiscr>]
130+
// cdb-check: [+0x[...]] __0 : 1234 [Type: unsigned int]
131+
132+
// cdb-command: dx -r2 arbitrary_discr2,d
133+
// cdb-check: arbitrary_discr2,d : Def [Type: enum2$<msvc_pretty_enums::ArbitraryDiscr>]
134+
// cdb-check: [+0x[...]] __0 : 5678 [Type: unsigned int]
135+
121136
#![feature(rustc_attrs)]
137+
#![feature(repr128)]
138+
#![feature(arbitrary_enum_discriminant)]
122139

123140
use std::num::{NonZeroI128, NonZeroU32};
124141

@@ -168,6 +185,18 @@ enum Wrapping128Niche {
168185
Z,
169186
}
170187

188+
#[repr(i128)]
189+
enum DirectTag128 {
190+
A(u32),
191+
B(u32),
192+
}
193+
194+
#[repr(u32)]
195+
enum ArbitraryDiscr {
196+
Abc(u32) = 1000,
197+
Def(u32) = 5000_000,
198+
}
199+
171200
fn main() {
172201
let a = Some(CStyleEnum::Low);
173202
let b = Option::<CStyleEnum>::None;
@@ -189,6 +218,9 @@ fn main() {
189218
let wrapping_niche128_none1 = Wrapping128Niche::Y;
190219
let wrapping_niche128_none2 = Wrapping128Niche::Z;
191220

221+
let direct_tag_128_a = DirectTag128::A(42);
222+
let direct_tag_128_b = DirectTag128::B(137);
223+
192224
let niche_w_fields_1_some = NicheLayoutWithFields1::A(&77, 7);
193225
let niche_w_fields_1_none = NicheLayoutWithFields1::B(99);
194226

@@ -205,6 +237,9 @@ fn main() {
205237
let niche_w_fields_std_result_ok: Result<Box<[u8]>, u64> = Ok(vec![1, 2, 3].into());
206238
let niche_w_fields_std_result_err: Result<Box<[u8]>, u64> = Err(789);
207239

240+
let arbitrary_discr1 = ArbitraryDiscr::Abc(1234);
241+
let arbitrary_discr2 = ArbitraryDiscr::Def(5678);
242+
208243
zzz(); // #break
209244
}
210245

0 commit comments

Comments
 (0)