Skip to content

Commit 721b622

Browse files
committed
Update cdb tests for expected output
Also an fix issue with tuple type names where we can't cast to them in natvis (required by the visualizer for `HashMap`) because of peculiarities with the natvis expression evaluator.
1 parent aac8a88 commit 721b622

File tree

8 files changed

+82
-68
lines changed

8 files changed

+82
-68
lines changed

compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,21 @@ pub fn push_debuginfo_type_name<'tcx>(
8181

8282
for component_type in component_types {
8383
push_debuginfo_type_name(tcx, component_type.expect_ty(), true, output, visited);
84-
output.push_str(", ");
84+
output.push(',');
85+
86+
// Natvis does not always like having spaces between parts of the type name
87+
// and this causes issues when we need to write a typename in natvis, for example
88+
// as part of a cast like the `HashMap` visualizer does.
89+
if !cpp_like_names {
90+
output.push(' ');
91+
}
8592
}
8693
if !component_types.is_empty() {
8794
output.pop();
88-
output.pop();
95+
96+
if !cpp_like_names {
97+
output.pop();
98+
}
8999
}
90100

91101
if cpp_like_names {

src/test/debuginfo/basic-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
// cdb-check:f64 : 3.500000 [Type: double]
130130
// cdb-command:.enable_unicode 1
131131
// cdb-command:dx s
132-
// cdb-check:s : 72 [Type: str]
132+
// cdb-check:s : "Hello, World!" [Type: str]
133133

134134
#![allow(unused_variables)]
135135
#![feature(omit_gdb_pretty_printer_section)]

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,43 @@
77
// so the best we can do is to make sure we are generating the right debuginfo
88

99
// cdb-command: dx -r2 a,!
10-
// cdb-check:a,! : Some({...}) [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>]
10+
// cdb-check:a,! [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>]
1111
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Some]
1212
// cdb-check: [+0x000] __0 : Low (0x2) [Type: msvc_pretty_enums::CStyleEnum]
1313
// cdb-check: [+0x000] discriminant : 0x2 [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Discriminant$]
1414

1515
// cdb-command: dx -r2 b,!
16-
// cdb-check:b,! : None [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>]
16+
// cdb-check:b,! [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>]
1717
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Some]
1818
// cdb-check: [+0x000] __0 : 0x11 [Type: msvc_pretty_enums::CStyleEnum]
1919
// cdb-check: [+0x000] discriminant : None (0x11) [Type: enum$<core::option::Option<enum$<msvc_pretty_enums::CStyleEnum> >, 2, 16, Some>::Discriminant$]
2020

2121
// cdb-command: dx -r2 c,!
22-
// cdb-check:c,! : Tag1 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
22+
// cdb-check:c,! [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
2323
// cdb-check: [+0x000] dataful_variant [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
2424
// cdb-check: [+0x000] my_data : 0x11 [Type: msvc_pretty_enums::CStyleEnum]
2525
// cdb-check: [+0x000] discriminant : Tag1 (0x11) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$]
2626

2727
// cdb-command: dx -r2 d,!
28-
// cdb-check:d,! : Data({...}) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
28+
// cdb-check:d,! [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
2929
// cdb-check: [+0x000] dataful_variant [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
3030
// cdb-check: [+0x000] my_data : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
3131
// cdb-check: [+0x000] discriminant : 0x10 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$]
3232

3333
// cdb-command: dx -r2 e,!
34-
// cdb-check:e,! : Tag2 [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
34+
// cdb-check:e,! [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>]
3535
// cdb-check: [+0x000] dataful_variant [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Data]
3636
// cdb-check: [+0x000] my_data : 0x13 [Type: msvc_pretty_enums::CStyleEnum]
3737
// cdb-check: [+0x000] discriminant : Tag2 (0x13) [Type: enum$<msvc_pretty_enums::NicheLayoutEnum, 2, 16, Data>::Discriminant$]
3838

3939
// cdb-command: dx -r2 f,!
40-
// cdb-check:f,! : Some({...}) [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
40+
// cdb-check:f,! [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
4141
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Some]
4242
// cdb-check: [+0x000] __0 : 0x[...] : 0x1 [Type: unsigned int *]
4343
// cdb-check: [+0x000] discriminant : 0x[...] [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Discriminant$]
4444

4545
// cdb-command: dx -r2 g,!
46-
// cdb-check:g,! : None [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
46+
// cdb-check:g,! [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>]
4747
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Some]
4848
// cdb-check: [+0x000] __0 : 0x0 [Type: unsigned int *]
4949
// cdb-check: [+0x000] discriminant : None (0x0) [Type: enum$<core::option::Option<ref$<u32> >, 1, [...], Some>::Discriminant$]
@@ -61,7 +61,7 @@
6161
// cdb-check:j : High (0x10) [Type: msvc_pretty_enums::CStyleEnum]
6262

6363
// cdb-command: dx -r2 k,!
64-
// cdb-check:k,! : Some({...}) [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
64+
// cdb-check:k,! [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
6565
// cdb-check: [+0x000] dataful_variant [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>::Some]
6666
// cdb-check: [+0x000] __0 [Type: alloc::string::String]
6767
// cdb-check: [+0x000] discriminant : 0x[...] [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>::Discriminant$]

src/test/debuginfo/pretty-std-collections-hash.rs

+5
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
// cdb-command: dx hash_map,d
7878
// cdb-check: ["0xe"] : 14 [Type: unsigned __int64]
7979

80+
// cdb-command: dx x
81+
8082
#![allow(unused_variables)]
8183
use std::collections::HashSet;
8284
use std::collections::HashMap;
@@ -95,6 +97,9 @@ fn main() {
9597
hash_map.insert(i as u64, i as u64);
9698
}
9799

100+
let x = &(123u64, 456u64);
101+
let string = "awefawefawe".to_string();
102+
98103
zzz(); // #break
99104
}
100105

src/test/debuginfo/pretty-std.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@
125125

126126
// cdb-command: dx some_string
127127
// NOTE: cdb fails to interpret debug info of Option enums on i686.
128-
// cdb-check:some_string : Some({...}) [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
129-
// cdb-check: [...] __0 : "IAMA optional string!" [Type: alloc::string::String]
128+
// cdb-check:some_string [Type: enum$<core::option::Option<alloc::string::String>, 1, [...], Some>]
130129

131130
#![allow(unused_variables)]
132131
use std::ffi::OsString;

src/test/debuginfo/simple-tuple.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -129,38 +129,38 @@
129129
// cdb-command: g
130130

131131
// cdb-command:dx noPadding8,d
132-
// cdb-check:noPadding8,d [...]: (-100, 100) [Type: tuple$<i8, u8>]
132+
// cdb-check:noPadding8,d [...]: (-100, 100) [Type: tuple$<i8,u8>]
133133
// cdb-check:[...][0] : -100 [Type: [...]]
134134
// cdb-check:[...][1] : 100 [Type: [...]]
135135
// cdb-command:dx noPadding16,d
136-
// cdb-check:noPadding16,d [...]: (0, 1, 2) [Type: tuple$<i16, i16, u16>]
136+
// cdb-check:noPadding16,d [...]: (0, 1, 2) [Type: tuple$<i16,i16,u16>]
137137
// cdb-check:[...][0] : 0 [Type: [...]]
138138
// cdb-check:[...][1] : 1 [Type: [...]]
139139
// cdb-check:[...][2] : 2 [Type: [...]]
140140
// cdb-command:dx noPadding32,d
141-
// cdb-check:noPadding32,d [...]: (3, 4.5[...], 5) [Type: tuple$<i32, f32, u32>]
141+
// cdb-check:noPadding32,d [...]: (3, 4.5[...], 5) [Type: tuple$<i32,f32,u32>]
142142
// cdb-check:[...][0] : 3 [Type: [...]]
143143
// cdb-check:[...][1] : 4.5[...] [Type: [...]]
144144
// cdb-check:[...][2] : 5 [Type: [...]]
145145
// cdb-command:dx noPadding64,d
146-
// cdb-check:noPadding64,d [...]: (6, 7.5[...], 8) [Type: tuple$<i64, f64, u64>]
146+
// cdb-check:noPadding64,d [...]: (6, 7.5[...], 8) [Type: tuple$<i64,f64,u64>]
147147
// cdb-check:[...][0] : 6 [Type: [...]]
148148
// cdb-check:[...][1] : 7.500000 [Type: [...]]
149149
// cdb-check:[...][2] : 8 [Type: [...]]
150150

151151
// cdb-command:dx internalPadding1,d
152-
// cdb-check:internalPadding1,d [...]: (9, 10) [Type: tuple$<i16, i32>]
152+
// cdb-check:internalPadding1,d [...]: (9, 10) [Type: tuple$<i16,i32>]
153153
// cdb-check:[...][0] : 9 [Type: short]
154154
// cdb-check:[...][1] : 10 [Type: int]
155155
// cdb-command:dx internalPadding2,d
156-
// cdb-check:internalPadding2,d [...]: (11, 12, 13, 14) [Type: tuple$<i16, i32, u32, u64>]
156+
// cdb-check:internalPadding2,d [...]: (11, 12, 13, 14) [Type: tuple$<i16,i32,u32,u64>]
157157
// cdb-check:[...][0] : 11 [Type: [...]]
158158
// cdb-check:[...][1] : 12 [Type: [...]]
159159
// cdb-check:[...][2] : 13 [Type: [...]]
160160
// cdb-check:[...][3] : 14 [Type: [...]]
161161

162162
// cdb-command:dx paddingAtEnd,d
163-
// cdb-check:paddingAtEnd,d [...]: (15, 16) [Type: tuple$<i32, i16>]
163+
// cdb-check:paddingAtEnd,d [...]: (15, 16) [Type: tuple$<i32,i16>]
164164
// cdb-check:[...][0] : 15 [Type: [...]]
165165
// cdb-check:[...][1] : 16 [Type: [...]]
166166

src/test/debuginfo/tuple-in-tuple.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -65,64 +65,64 @@
6565
// cdb-command: g
6666

6767
// cdb-command:dx no_padding1,d
68-
// cdb-check:no_padding1,d [...]: ((0, 1), 2, 3) [Type: tuple$<tuple$<u32, u32>, u32, u32>]
69-
// cdb-check:[...][0] : (0, 1) [Type: tuple$<u32, u32>]
68+
// cdb-check:no_padding1,d [...]: ((0, 1), 2, 3) [Type: tuple$<tuple$<u32,u32>,u32,u32>]
69+
// cdb-check:[...][0] : (0, 1) [Type: tuple$<u32,u32>]
7070
// cdb-check:[...][1] : 2 [Type: [...]]
7171
// cdb-check:[...][2] : 3 [Type: [...]]
7272
// cdb-command:dx no_padding1.__0,d
73-
// cdb-check:no_padding1.__0,d [...]: (0, 1) [Type: tuple$<u32, u32>]
73+
// cdb-check:no_padding1.__0,d [...]: (0, 1) [Type: tuple$<u32,u32>]
7474
// cdb-check:[...][0] : 0 [Type: [...]]
7575
// cdb-check:[...][1] : 1 [Type: [...]]
7676
// cdb-command:dx no_padding2,d
77-
// cdb-check:no_padding2,d [...]: (4, (5, 6), 7) [Type: tuple$<u32, tuple$<u32, u32>, u32>]
77+
// cdb-check:no_padding2,d [...]: (4, (5, 6), 7) [Type: tuple$<u32,tuple$<u32,u32>,u32>]
7878
// cdb-check:[...][0] : 4 [Type: [...]]
79-
// cdb-check:[...][1] : (5, 6) [Type: tuple$<u32, u32>]
79+
// cdb-check:[...][1] : (5, 6) [Type: tuple$<u32,u32>]
8080
// cdb-check:[...][2] : 7 [Type: [...]]
8181
// cdb-command:dx no_padding2.__1,d
82-
// cdb-check:no_padding2.__1,d [...]: (5, 6) [Type: tuple$<u32, u32>]
82+
// cdb-check:no_padding2.__1,d [...]: (5, 6) [Type: tuple$<u32,u32>]
8383
// cdb-check:[...][0] : 5 [Type: [...]]
8484
// cdb-check:[...][1] : 6 [Type: [...]]
8585
// cdb-command:dx no_padding3,d
86-
// cdb-check:no_padding3,d [...]: (8, 9, (10, 11)) [Type: tuple$<u32, u32, tuple$<u32, u32> >]
86+
// cdb-check:no_padding3,d [...]: (8, 9, (10, 11)) [Type: tuple$<u32,u32,tuple$<u32,u32> >]
8787
// cdb-check:[...][0] : 8 [Type: [...]]
8888
// cdb-check:[...][1] : 9 [Type: [...]]
89-
// cdb-check:[...][2] : (10, 11) [Type: tuple$<u32, u32>]
89+
// cdb-check:[...][2] : (10, 11) [Type: tuple$<u32,u32>]
9090
// cdb-command:dx no_padding3.__2,d
91-
// cdb-check:no_padding3.__2,d [...]: (10, 11) [Type: tuple$<u32, u32>]
91+
// cdb-check:no_padding3.__2,d [...]: (10, 11) [Type: tuple$<u32,u32>]
9292
// cdb-check:[...][0] : 10 [Type: [...]]
9393
// cdb-check:[...][1] : 11 [Type: [...]]
9494

9595
// cdb-command:dx internal_padding1,d
96-
// cdb-check:internal_padding1,d [...]: (12, (13, 14)) [Type: tuple$<i16, tuple$<i32, i32> >]
96+
// cdb-check:internal_padding1,d [...]: (12, (13, 14)) [Type: tuple$<i16,tuple$<i32,i32> >]
9797
// cdb-check:[...][0] : 12 [Type: [...]]
98-
// cdb-check:[...][1] : (13, 14) [Type: tuple$<i32, i32>]
98+
// cdb-check:[...][1] : (13, 14) [Type: tuple$<i32,i32>]
9999
// cdb-command:dx internal_padding1.__1,d
100-
// cdb-check:internal_padding1.__1,d [...]: (13, 14) [Type: tuple$<i32, i32>]
100+
// cdb-check:internal_padding1.__1,d [...]: (13, 14) [Type: tuple$<i32,i32>]
101101
// cdb-check:[...][0] : 13 [Type: [...]]
102102
// cdb-check:[...][1] : 14 [Type: [...]]
103103
// cdb-command:dx internal_padding2,d
104-
// cdb-check:internal_padding2,d [...]: (15, (16, 17)) [Type: tuple$<i16, tuple$<i16, i32> >]
104+
// cdb-check:internal_padding2,d [...]: (15, (16, 17)) [Type: tuple$<i16,tuple$<i16,i32> >]
105105
// cdb-check:[...][0] : 15 [Type: [...]]
106-
// cdb-check:[...][1] : (16, 17) [Type: tuple$<i16, i32>]
106+
// cdb-check:[...][1] : (16, 17) [Type: tuple$<i16,i32>]
107107
// cdb-command:dx internal_padding2.__1,d
108-
// cdb-check:internal_padding2.__1,d [...]: (16, 17) [Type: tuple$<i16, i32>]
108+
// cdb-check:internal_padding2.__1,d [...]: (16, 17) [Type: tuple$<i16,i32>]
109109
// cdb-check:[...][0] : 16 [Type: [...]]
110110
// cdb-check:[...][1] : 17 [Type: [...]]
111111

112112
// cdb-command:dx padding_at_end1,d
113-
// cdb-check:padding_at_end1,d [...]: (18, (19, 20)) [Type: tuple$<i32, tuple$<i32, i16> >]
113+
// cdb-check:padding_at_end1,d [...]: (18, (19, 20)) [Type: tuple$<i32,tuple$<i32,i16> >]
114114
// cdb-check:[...][0] : 18 [Type: [...]]
115-
// cdb-check:[...][1] : (19, 20) [Type: tuple$<i32, i16>]
115+
// cdb-check:[...][1] : (19, 20) [Type: tuple$<i32,i16>]
116116
// cdb-command:dx padding_at_end1.__1,d
117-
// cdb-check:padding_at_end1.__1,d [...][Type: tuple$<i32, i16>]
117+
// cdb-check:padding_at_end1.__1,d [...][Type: tuple$<i32,i16>]
118118
// cdb-check:[...][0] : 19 [Type: [...]]
119119
// cdb-check:[...][1] : 20 [Type: [...]]
120120
// cdb-command:dx padding_at_end2,d
121-
// cdb-check:padding_at_end2,d [...]: ((21, 22), 23) [Type: tuple$<tuple$<i32, i16>, i32>]
122-
// cdb-check:[...][0] : (21, 22) [Type: tuple$<i32, i16>]
121+
// cdb-check:padding_at_end2,d [...]: ((21, 22), 23) [Type: tuple$<tuple$<i32,i16>,i32>]
122+
// cdb-check:[...][0] : (21, 22) [Type: tuple$<i32,i16>]
123123
// cdb-check:[...][1] : 23 [Type: [...]]
124124
// cdb-command:dx padding_at_end2.__0,d
125-
// cdb-check:padding_at_end2.__0,d [...]: (21, 22) [Type: tuple$<i32, i16>]
125+
// cdb-check:padding_at_end2.__0,d [...]: (21, 22) [Type: tuple$<i32,i16>]
126126
// cdb-check:[...][0] : 21 [Type: [...]]
127127
// cdb-check:[...][1] : 22 [Type: [...]]
128128

0 commit comments

Comments
 (0)