Skip to content

Commit 8e10c4d

Browse files
committed
Modify type names on MSVC to make strings and slices .natvis compatible.
1 parent 5d5e67a commit 8e10c4d

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/etc/natvis/intrinsic.natvis

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
3+
<Type Name="str">
4+
<DisplayString>{data_ptr,[length]}</DisplayString>
5+
<StringView>data_ptr,[length]</StringView>
6+
<Expand>
7+
<Item Name="[size]" ExcludeView="simple">length</Item>
8+
<ArrayItems>
9+
<Size>length</Size>
10+
<ValuePointer>data_ptr</ValuePointer>
11+
</ArrayItems>
12+
</Expand>
13+
</Type>
14+
<Type Name="slice&lt;*&gt;">
15+
<DisplayString>{{ length={length} }}</DisplayString>
16+
<Expand>
17+
<Item Name="[size]" ExcludeView="simple">length</Item>
18+
<ArrayItems>
19+
<Size>length</Size>
20+
<ValuePointer>data_ptr</ValuePointer>
21+
</ArrayItems>
22+
</Expand>
23+
</Type>
24+
</AutoVisualizer>

src/librustc_trans/debuginfo/type_names.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,27 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
6161
output.push(')');
6262
},
6363
ty::TyRawPtr(ty::TypeAndMut { ty: inner_type, mutbl } ) => {
64-
output.push('*');
64+
let is_like_msvc = cx.sess().target.target.options.is_like_msvc;
65+
66+
if !is_like_msvc {output.push('*');}
6567
match mutbl {
6668
hir::MutImmutable => output.push_str("const "),
6769
hir::MutMutable => output.push_str("mut "),
6870
}
6971

7072
push_debuginfo_type_name(cx, inner_type, true, output);
73+
if is_like_msvc {output.push('*');}
7174
},
7275
ty::TyRef(_, ty::TypeAndMut { ty: inner_type, mutbl }) => {
73-
output.push('&');
76+
let is_like_msvc = cx.sess().target.target.options.is_like_msvc;
77+
78+
if !is_like_msvc {output.push('&');}
7479
if mutbl == hir::MutMutable {
7580
output.push_str("mut ");
7681
}
7782

7883
push_debuginfo_type_name(cx, inner_type, true, output);
84+
if is_like_msvc {output.push('*');}
7985
},
8086
ty::TyArray(inner_type, len) => {
8187
output.push('[');
@@ -84,9 +90,10 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
8490
output.push(']');
8591
},
8692
ty::TySlice(inner_type) => {
87-
output.push('[');
93+
let is_like_msvc = cx.sess().target.target.options.is_like_msvc;
94+
output.push_str(if is_like_msvc {"slice<"} else {"["});
8895
push_debuginfo_type_name(cx, inner_type, true, output);
89-
output.push(']');
96+
output.push(if is_like_msvc {'>'} else {']'});
9097
},
9198
ty::TyDynamic(ref trait_data, ..) => {
9299
if let Some(principal) = trait_data.principal() {

0 commit comments

Comments
 (0)