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