]> git.lizzy.rs Git - rust.git/blob - src/test/debuginfo/msvc-pretty-enums.rs
Auto merge of #86580 - BoxyUwU:cgd-subst-ice, r=nikomatsakis
[rust.git] / src / test / debuginfo / msvc-pretty-enums.rs
1 // only-cdb
2 // ignore-tidy-linelength
3 // compile-flags:-g
4
5 // cdb-command: g
6
7 // Note: The natvis used to visualize niche-layout enums don't work correctly in cdb
8 //       so the best we can do is to make sure we are generating the right debuginfo.
9 //       Therefore, we use the `!` [format specifier](https://docs.microsoft.com/en-us/visualstudio/debugger/format-specifiers-in-cpp?view=vs-2019#BKMK_Visual_Studio_2012_format_specifiers)
10 //       to disable the natvis for a given expression. We also provide the `-r2` flag
11 //       to expand the expression 2 levels.
12
13 // cdb-command: dx -r2 a,!
14 // cdb-check:a,!              [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>]
15 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Some]
16 // cdb-check:        [+0x000] __0              : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum]
17 // cdb-check:    [+0x000] discriminant     : 0x2 [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Discriminant$]
18
19 // cdb-command: dx -r2 b,!
20 // cdb-check:b,!              [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>]
21 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Some]
22 // cdb-check:        [+0x000] __0              : 0x11 [Type: msvc_pretty_enums::CStyleEnum]
23 // cdb-check:    [+0x000] discriminant     : None (0x11) [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Discriminant$]
24
25 // cdb-command: dx -r2 c,!
26 // cdb-check:c,!              [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
27 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
28 // cdb-check:        [+0x000] my_data          : 0x11 [Type: msvc_pretty_enums::CStyleEnum]
29 // cdb-check:    [+0x000] discriminant     : Tag1 (0x11) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$]
30
31 // cdb-command: dx -r2 d,!
32 // cdb-check:d,!              [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
33 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
34 // cdb-check:        [+0x000] my_data          : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
35 // cdb-check:    [+0x000] discriminant     : 0x10 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$]
36
37 // cdb-command: dx -r2 e,!
38 // cdb-check:e,!              [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
39 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
40 // cdb-check:        [+0x000] my_data          : 0x13 [Type: msvc_pretty_enums::CStyleEnum]
41 // cdb-check:    [+0x000] discriminant     : Tag2 (0x13) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$]
42
43 // cdb-command: dx -r2 f,!
44 // cdb-check:f,!              [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
45 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Some]
46 // cdb-check:        [+0x000] __0              : 0x[...] : 0x1 [Type: unsigned int *]
47 // cdb-check:    [+0x000] discriminant     : 0x[...] [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Discriminant$]
48
49 // cdb-command: dx -r2 g,!
50 // cdb-check:g,!              [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
51 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Some]
52 // cdb-check:        [+0x000] __0              : 0x0 [Type: unsigned int *]
53 // cdb-check:    [+0x000] discriminant     : None (0x0) [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Discriminant$]
54
55 // cdb-command: dx -r2 h,!
56 // cdb-check:h,!              : Some [Type: enum$<core::option::Option<u32> >]
57 // cdb-check:    [+0x000] variant0         [Type: enum$<core::option::Option<u32> >::None]
58 // cdb-check:    [+0x000] variant1         [Type: enum$<core::option::Option<u32> >::Some]
59 // cdb-check:        [+0x004] __0              : 0xc [Type: unsigned int]
60 // cdb-check:    [+0x000] discriminant     : Some (0x1) [Type: core::option::Option]
61
62 // cdb-command: dx h
63 // cdb-check:h                : Some [Type: enum$<core::option::Option<u32> >]
64 // cdb-check:    [<Raw View>]     [Type: enum$<core::option::Option<u32> >]
65 // cdb-check:    [variant]        : Some
66 // cdb-check:    [+0x004] __0              : 0xc [Type: unsigned int]
67
68 // cdb-command: dx -r2 i,!
69 // cdb-check:i,!              : None [Type: enum$<core::option::Option<u32> >]
70 // cdb-check:    [+0x000] variant0         [Type: enum$<core::option::Option<u32> >::None]
71 // cdb-check:    [+0x000] variant1         [Type: enum$<core::option::Option<u32> >::Some]
72 // cdb-check:        [+0x004] __0              : 0x[...] [Type: unsigned int]
73 // cdb-check:    [+0x000] discriminant     : None (0x0) [Type: core::option::Option]
74
75 // cdb-command: dx i
76 // cdb-check:i                : None [Type: enum$<core::option::Option<u32> >]
77 // cdb-check:    [<Raw View>]     [Type: enum$<core::option::Option<u32> >]
78 // cdb-check:    [variant]        : None
79
80 // cdb-command: dx j
81 // cdb-check:j                : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
82
83 // cdb-command: dx -r2 k,!
84 // cdb-check:k,!              [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
85 // cdb-check:    [+0x000] dataful_variant  [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>::Some]
86 // cdb-check:        [+0x000] __0              [Type: alloc::string::String]
87 // cdb-check:    [+0x000] discriminant     : 0x[...] [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>::Discriminant$]
88
89 // cdb-command: dx -r2 l,!
90 // cdb-check:l,!              : $T2 [Type: enum$<core::result::Result<u32,enum$<msvc_pretty_enums::Empty> >, Ok>]
91 // cdb-check:    [+0x000] Ok               [Type: enum$<core::result::Result<u32,enum$<msvc_pretty_enums::Empty> >, Ok>::Ok]
92 // cdb-check:        [+0x000] __0              : 0x2a [Type: unsigned int]
93
94 pub enum CStyleEnum {
95     Low = 2,
96     High = 16,
97 }
98
99 pub enum NicheLayoutEnum {
100     Tag1,
101     Data { my_data: CStyleEnum },
102     Tag2,
103 }
104
105 pub enum Empty { }
106
107 fn main() {
108     let a = Some(CStyleEnum::Low);
109     let b = Option::<CStyleEnum>::None;
110     let c = NicheLayoutEnum::Tag1;
111     let d = NicheLayoutEnum::Data { my_data: CStyleEnum::High };
112     let e = NicheLayoutEnum::Tag2;
113     let f = Some(&1u32);
114     let g = Option::<&'static u32>::None;
115     let h = Some(12u32);
116     let i = Option::<u32>::None;
117     let j = CStyleEnum::High;
118     let k = Some("IAMA optional string!".to_string());
119     let l = Result::<u32, Empty>::Ok(42);
120
121     zzz(); // #break
122 }
123
124 fn zzz() { () }