7 // cdb-check:a : Some [Type: enum$<core::option::Option<msvc_pretty_enums::CStyleEnum> >]
8 // cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum]
11 // cdb-check:b : None [Type: enum$<core::option::Option<msvc_pretty_enums::CStyleEnum> >]
14 // cdb-check:c : Tag1 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum>]
17 // cdb-check:d : Data [Type: enum$<msvc_pretty_enums::NicheLayoutEnum>]
18 // cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
21 // cdb-check:e : Tag2 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum>]
24 // cdb-check:f : Some [Type: enum$<core::option::Option<ref$<u32> > >]
25 // cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *]
28 // cdb-check:g : None [Type: enum$<core::option::Option<ref$<u32> > >]
31 // cdb-check:h : Some [Type: enum$<core::option::Option<u32> >]
32 // cdb-check: [+0x004] __0 : 0xc [Type: unsigned int]
35 // cdb-check:i : None [Type: enum$<core::option::Option<u32> >]
38 // cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
41 // cdb-check:k : Some [Type: enum$<core::option::Option<alloc::string::String> >]
42 // cdb-check: [+0x000] __0 : "IAMA optional string!" [Type: alloc::string::String]
45 // cdb-check:l : Ok [Type: enum$<core::result::Result<u32,enum$<msvc_pretty_enums::Empty> > >]
46 // cdb-check: [+0x000] __0 : 0x2a [Type: unsigned int]
48 // cdb-command: dx niche128_some
49 // cdb-check:niche128_some : Some [Type: enum$<core::option::Option<core::num::nonzero::NonZeroI128> >]
50 // Note: we can't actually read the value of the field because CDB cannot handle 128 bit integers.
51 // cdb-check: [+0x000] __0 [...] [Type: core::num::nonzero::NonZeroI128]
53 // cdb-command: dx niche128_none
54 // cdb-check: niche128_none : None [Type: enum$<core::option::Option<core::num::nonzero::NonZeroI128> >]
56 // cdb-command: dx niche_w_fields_1_some,d
57 // cdb-check: niche_w_fields_1_some,d : A [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields1>]
58 // cdb-check: [+0x[...]] __0 : 0x[...] : 77 [Type: unsigned char *]
59 // cdb-check: [+0x[...]] __1 : 7 [Type: unsigned int]
61 // cdb-command: dx niche_w_fields_1_none,d
62 // cdb-check: niche_w_fields_1_none,d : B [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields1>]
63 // cdb-check: [+0x[...]] __0 : 99 [Type: unsigned int]
65 // cdb-command: dx niche_w_fields_2_some,d
66 // cdb-check: niche_w_fields_2_some,d : A [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields2>]
67 // cdb-check: [<Raw View>] [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields2>]
68 // cdb-check: [+0x[...]] __0 : 800 [Type: core::num::nonzero::NonZeroU32]
69 // cdb-check: [+0x[...]] __1 : 900 [Type: unsigned __int64]
71 // cdb-command: dx niche_w_fields_2_none,d
72 // cdb-check: niche_w_fields_2_none,d : B [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields2>]
73 // cdb-check: [+0x[...]] __0 : 1000 [Type: unsigned __int64]
75 // cdb-command: dx niche_w_fields_3_some,d
76 // cdb-check: niche_w_fields_3_some,d : A [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields3>]
77 // cdb-check: [+0x[...]] __0 : 137 [Type: unsigned char]
78 // cdb-check: [+0x[...]] __1 : true [Type: bool]
80 // cdb-command: dx niche_w_fields_3_niche1,d
81 // cdb-check: niche_w_fields_3_niche1,d : B [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields3>]
82 // cdb-check: [+0x[...]] __0 : 12 [Type: unsigned char]
84 // cdb-command: dx niche_w_fields_3_niche2,d
85 // cdb-check: niche_w_fields_3_niche2,d : C [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields3>]
86 // cdb-check: [+0x[...]] __0 : false [Type: bool]
88 // cdb-command: dx niche_w_fields_3_niche3,d
89 // cdb-check: niche_w_fields_3_niche3,d : D [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields3>]
90 // cdb-check: [+0x[...]] __0 : 34 [Type: unsigned char]
92 // cdb-command: dx niche_w_fields_3_niche4,d
93 // cdb-check: niche_w_fields_3_niche4,d : E [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields3>]
94 // cdb-check: [+0x[...]] __0 : 56 [Type: unsigned char]
96 // cdb-command: dx niche_w_fields_3_niche5,d
97 // cdb-check: niche_w_fields_3_niche5,d : F [Type: enum$<msvc_pretty_enums::NicheLayoutWithFields3>]
99 // cdb-command: dx -r3 niche_w_fields_std_result_ok,d
100 // cdb-check: niche_w_fields_std_result_ok,d : Ok [Type: enum$<core::result::Result<alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>,u64> >]
101 // cdb-check: [+0x[...]] __0 [Type: alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>]
102 // cdb-check: [+0x[...]] data_ptr : [...]
103 // cdb-check: [+0x[...]] length : 3 [...]
105 // cdb-command: dx -r3 niche_w_fields_std_result_err,d
106 // cdb-check: niche_w_fields_std_result_err,d : Err [Type: enum$<core::result::Result<alloc::boxed::Box<slice$<u8>,alloc::alloc::Global>,u64> >]
107 // cdb-check: [+0x[...]] __0 : 789 [Type: unsigned __int64]
109 use std::num::{NonZeroI128, NonZeroU32};
111 pub enum CStyleEnum {
116 pub enum NicheLayoutEnum {
118 Data { my_data: CStyleEnum },
124 // The following three types will use a niche layout once
125 // https://github.com/rust-lang/rust/pull/94075 is merged:
126 enum NicheLayoutWithFields1<'a> {
131 enum NicheLayoutWithFields2 {
132 A(NonZeroU32, usize),
136 enum NicheLayoutWithFields3 {
146 let a = Some(CStyleEnum::Low);
147 let b = Option::<CStyleEnum>::None;
148 let c = NicheLayoutEnum::Tag1;
149 let d = NicheLayoutEnum::Data { my_data: CStyleEnum::High };
150 let e = NicheLayoutEnum::Tag2;
152 let g = Option::<&'static u32>::None;
154 let i = Option::<u32>::None;
155 let j = CStyleEnum::High;
156 let k = Some("IAMA optional string!".to_string());
157 let l = Result::<u32, Empty>::Ok(42);
158 let niche128_some = Some(NonZeroI128::new(123456).unwrap());
159 let niche128_none: Option<NonZeroI128> = None;
161 let niche_w_fields_1_some = NicheLayoutWithFields1::A(&77, 7);
162 let niche_w_fields_1_none = NicheLayoutWithFields1::B(99);
164 let niche_w_fields_2_some = NicheLayoutWithFields2::A(NonZeroU32::new(800).unwrap(), 900);
165 let niche_w_fields_2_none = NicheLayoutWithFields2::B(1000);
167 let niche_w_fields_3_some = NicheLayoutWithFields3::A(137, true);
168 let niche_w_fields_3_niche1 = NicheLayoutWithFields3::B(12);
169 let niche_w_fields_3_niche2 = NicheLayoutWithFields3::C(false);
170 let niche_w_fields_3_niche3 = NicheLayoutWithFields3::D(34);
171 let niche_w_fields_3_niche4 = NicheLayoutWithFields3::E(56);
172 let niche_w_fields_3_niche5 = NicheLayoutWithFields3::F;
174 let niche_w_fields_std_result_ok: Result<Box<[u8]>, u64> = Ok(vec![1, 2, 3].into());
175 let niche_w_fields_std_result_err: Result<Box<[u8]>, u64> = Err(789);