Skip to content

Commit 2a9fa20

Browse files
committed
Add/update tests
1 parent 141546c commit 2a9fa20

File tree

2 files changed

+107
-3
lines changed

2 files changed

+107
-3
lines changed
+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// only-cdb
2+
// compile-flags:-g
3+
4+
// cdb-command: g
5+
6+
// Note: The natvis used to visualize niche-layout enums don't work correctly in cdb
7+
// so the best we can do is to make sure we are generating the right debuginfo
8+
9+
// cdb-command: dx -r2 a,!
10+
// cdb-check:a,! [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>]
11+
// cdb-check: [+0x000] dataful_variant [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::Some]
12+
// cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum]
13+
// cdb-check: [+0x000] discriminant$ [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::discriminant$]
14+
// cdb-check: [+0x000] discriminant : 0x2 [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::tag$]
15+
16+
// cdb-command: dx -r2 b,!
17+
// cdb-check:b,! [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>]
18+
// cdb-check: [+0x000] dataful_variant [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::Some]
19+
// cdb-check: [+0x000] __0 : 0x11 [Type: msvc_pretty_enums::CStyleEnum]
20+
// cdb-check: [+0x000] discriminant$ [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::discriminant$]
21+
// cdb-check: [+0x000] discriminant : None (0x11) [Type: _enum<core::option::Option<_enum<msvc_pretty_enums::CStyleEnum>>, 2, 16, Some>::tag$]
22+
23+
// cdb-command: dx -r2 c,!
24+
// cdb-check:c,! [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
25+
// cdb-check: [+0x000] dataful_variant [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
26+
// cdb-check: [+0x000] my_data : 0x11 [Type: msvc_pretty_enums::CStyleEnum]
27+
// cdb-check: [+0x000] discriminant$ [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::discriminant$]
28+
// cdb-check: [+0x000] discriminant : Tag1 (0x11) [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::tag$]
29+
30+
// cdb-command: dx -r2 d,!
31+
// cdb-check:d,! [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
32+
// cdb-check: [+0x000] dataful_variant [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
33+
// cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
34+
// cdb-check: [+0x000] discriminant$ [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::discriminant$]
35+
// cdb-check: [+0x000] discriminant : 0x10 [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::tag$]
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$ [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::discriminant$]
42+
// cdb-check: [+0x000] discriminant : Tag2 (0x13) [Type: _enum<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::tag$]
43+
44+
// cdb-command: dx -r2 f,!
45+
// cdb-check:f,! [Type: _enum<core::option::Option<u32*>, 1, [...], Some>]
46+
// cdb-check: [+0x000] dataful_variant [Type: _enum<core::option::Option<u32*>, 1, [...], Some>::Some]
47+
// cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *]
48+
// cdb-check: [+0x000] discriminant$ [Type: _enum<core::option::Option<u32*>, 1, [...], Some>::discriminant$]
49+
// cdb-check: [+0x000] discriminant : 0x[...] [Type: _enum<core::option::Option<u32*>, 1, [...], Some>::tag$]
50+
51+
// cdb-command: dx -r2 g,!
52+
// cdb-check:g,! [Type: _enum<core::option::Option<u32*>, 1, [...], Some>]
53+
// cdb-check: [+0x000] dataful_variant [Type: _enum<core::option::Option<u32*>, 1, [...], Some>::Some]
54+
// cdb-check: [+0x000] __0 : 0x0 [Type: unsigned int *]
55+
// cdb-check: [+0x000] discriminant$ [Type: _enum<core::option::Option<u32*>, 1, [...], Some>::discriminant$]
56+
// cdb-check: [+0x000] discriminant : None (0x0) [Type: _enum<core::option::Option<u32*>, 1, [...], Some>::tag$]
57+
58+
// cdb-command: dx h
59+
// cdb-check:h : Some [Type: _enum<core::option::Option<u32>>]
60+
// cdb-check: [+0x000] variant$ : Some (0x1) [Type: core::option::Option]
61+
// cdb-check: [+0x004] __0 : 0xc [Type: unsigned int]
62+
63+
// cdb-command: dx i
64+
// cdb-check:i : None [Type: _enum<core::option::Option<u32>>]
65+
// cdb-check: [+0x000] variant$ : None (0x0) [Type: core::option::Option]
66+
67+
// cdb-command: dx j
68+
// cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
69+
70+
// cdb-command: dx -r2 k,!
71+
// cdb-check:k,! [Type: _enum<core::option::Option<alloc::string::String>, 1, [...], Some>]
72+
// cdb-check: [+0x000] dataful_variant [Type: _enum<core::option::Option<alloc::string::String>, 1, [...], Some>::Some]
73+
// cdb-check: [+0x000] __0 [Type: alloc::string::String]
74+
// cdb-check: [+0x000] discriminant$ [Type: _enum<core::option::Option<alloc::string::String>, 1, [...], Some>::discriminant$]
75+
// cdb-check: [+0x000] discriminant : 0x[...] [Type: _enum<core::option::Option<alloc::string::String>, 1, [...], Some>::tag$]
76+
77+
pub enum CStyleEnum {
78+
Low = 2,
79+
High = 16,
80+
}
81+
82+
pub enum NicheLayoutEnum {
83+
Tag1,
84+
Data { my_data: CStyleEnum },
85+
Tag2,
86+
}
87+
88+
fn main() {
89+
let a = Some(CStyleEnum::Low);
90+
let b = Option::<CStyleEnum>::None;
91+
let c = NicheLayoutEnum::Tag1;
92+
let d = NicheLayoutEnum::Data { my_data: CStyleEnum::High };
93+
let e = NicheLayoutEnum::Tag2;
94+
let f = Some(&1u32);
95+
let g = Option::<&'static u32>::None;
96+
let h = Some(12u32);
97+
let i = Option::<u32>::None;
98+
let j = CStyleEnum::High;
99+
let k = Some("IAMA optional string!".to_string());
100+
101+
zzz(); // #break
102+
}
103+
104+
fn zzz() { () }

src/test/debuginfo/pretty-std.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@
111111
// NOTE: OsString doesn't have a .natvis entry yet.
112112

113113
// cdb-command: dx some
114-
// cdb-check:some : Some(8) [Type: [...]::Option<i16>]
114+
// cdb-check:some : Some [Type: _enum<core::option::Option<i16>>]
115115
// cdb-command: dx none
116-
// cdb-check:none : None [Type: [...]::Option<i64>]
116+
// cdb-check:none : None [Type: _enum<core::option::Option<i64>>]
117117
// cdb-command: dx some_string
118-
// cdb-check:some_string : Some("IAMA optional string!") [[...]::Option<[...]::String>]
118+
// cdb-check:some_string [Type: _enum<core::option::Option<alloc::string::String>, 1, 18446744073709551615, Some>]
119119

120120
#![allow(unused_variables)]
121121
use std::ffi::OsString;

0 commit comments

Comments
 (0)