@@ -36,6 +36,10 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
36
36
t : Ty < ' tcx > ,
37
37
qualified : bool ,
38
38
output : & mut String ) {
39
+ // When targeting MSVC, emit C++ style type names for compatability with
40
+ // .natvis visualizers (and perhaps other existing native debuggers?)
41
+ let cpp_like_names = cx. sess ( ) . target . target . options . is_like_msvc ;
42
+
39
43
match t. sty {
40
44
ty:: TyBool => output. push_str ( "bool" ) ,
41
45
ty:: TyChar => output. push_str ( "char" ) ,
@@ -61,27 +65,33 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
61
65
output. push ( ')' ) ;
62
66
} ,
63
67
ty:: TyRawPtr ( ty:: TypeAndMut { ty : inner_type, mutbl } ) => {
64
- let is_like_msvc = cx . sess ( ) . target . target . options . is_like_msvc ;
65
-
66
- if !is_like_msvc { output . push ( '*' ) ; }
68
+ if !cpp_like_names {
69
+ output . push ( '*' ) ;
70
+ }
67
71
match mutbl {
68
72
hir:: MutImmutable => output. push_str ( "const " ) ,
69
73
hir:: MutMutable => output. push_str ( "mut " ) ,
70
74
}
71
75
72
76
push_debuginfo_type_name ( cx, inner_type, true , output) ;
73
- if is_like_msvc { output. push ( '*' ) ; }
77
+
78
+ if cpp_like_names {
79
+ output. push ( '*' ) ;
80
+ }
74
81
} ,
75
82
ty:: TyRef ( _, ty:: TypeAndMut { ty : inner_type, mutbl } ) => {
76
- let is_like_msvc = cx . sess ( ) . target . target . options . is_like_msvc ;
77
-
78
- if !is_like_msvc { output . push ( '&' ) ; }
83
+ if !cpp_like_names {
84
+ output . push ( '&' ) ;
85
+ }
79
86
if mutbl == hir:: MutMutable {
80
87
output. push_str ( "mut " ) ;
81
88
}
82
89
83
90
push_debuginfo_type_name ( cx, inner_type, true , output) ;
84
- if is_like_msvc { output. push ( '*' ) ; }
91
+
92
+ if cpp_like_names {
93
+ output. push ( '*' ) ;
94
+ }
85
95
} ,
86
96
ty:: TyArray ( inner_type, len) => {
87
97
output. push ( '[' ) ;
@@ -90,10 +100,19 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
90
100
output. push ( ']' ) ;
91
101
} ,
92
102
ty:: TySlice ( inner_type) => {
93
- let is_like_msvc = cx. sess ( ) . target . target . options . is_like_msvc ;
94
- output. push_str ( if is_like_msvc { "slice<" } else { "[" } ) ;
103
+ if cpp_like_names {
104
+ output. push_str ( "slice<" ) ;
105
+ } else {
106
+ output. push ( '[' ) ;
107
+ }
108
+
95
109
push_debuginfo_type_name ( cx, inner_type, true , output) ;
96
- output. push ( if is_like_msvc { '>' } else { ']' } ) ;
110
+
111
+ if cpp_like_names {
112
+ output. push ( '>' ) ;
113
+ } else {
114
+ output. push ( ']' ) ;
115
+ }
97
116
} ,
98
117
ty:: TyDynamic ( ref trait_data, ..) => {
99
118
if let Some ( principal) = trait_data. principal ( ) {
0 commit comments