@@ -31,24 +31,6 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
31
31
output : & mut String ,
32
32
visited : & mut FxHashSet < Ty < ' tcx > > ) {
33
33
34
- // We've encountered a weird 'recursive type'
35
- // Currently, the only way to generate such a type
36
- // is by using 'impl trait':
37
- //
38
- // fn foo() -> impl Copy { foo }
39
- //
40
- // There's not really a sensible name we can generate,
41
- // since we don't include 'impl trait' types (e.g. ty::Opaque)
42
- // in the output
43
- //
44
- // Since we need to generate *something*, we just
45
- // use a dummy string that should make it clear
46
- // that something unusual is going on
47
- if !visited. insert ( t) {
48
- output. push_str ( "<recursive_type>" ) ;
49
- return ;
50
- }
51
-
52
34
// When targeting MSVC, emit C++ style type names for compatibility with
53
35
// .natvis visualizers (and perhaps other existing native debuggers?)
54
36
let cpp_like_names = cx. sess ( ) . target . target . options . is_like_msvc ;
@@ -141,6 +123,25 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
141
123
}
142
124
} ,
143
125
ty:: FnDef ( ..) | ty:: FnPtr ( _) => {
126
+ // We've encountered a weird 'recursive type'
127
+ // Currently, the only way to generate such a type
128
+ // is by using 'impl trait':
129
+ //
130
+ // fn foo() -> impl Copy { foo }
131
+ //
132
+ // There's not really a sensible name we can generate,
133
+ // since we don't include 'impl trait' types (e.g. ty::Opaque)
134
+ // in the output
135
+ //
136
+ // Since we need to generate *something*, we just
137
+ // use a dummy string that should make it clear
138
+ // that something unusual is going on
139
+ if !visited. insert ( t) {
140
+ output. push_str ( "<recursive_type>" ) ;
141
+ return ;
142
+ }
143
+
144
+
144
145
let sig = t. fn_sig ( cx. tcx ) ;
145
146
if sig. unsafety ( ) == hir:: Unsafety :: Unsafe {
146
147
output. push_str ( "unsafe " ) ;
@@ -179,6 +180,18 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
179
180
output. push_str ( " -> " ) ;
180
181
push_debuginfo_type_name ( cx, sig. output ( ) , true , output, visited) ;
181
182
}
183
+
184
+
185
+ // We only keep the type in 'visited'
186
+ // for the duration of the body of this method.
187
+ // It's fine for a particular function type
188
+ // to show up multiple times in one overall type
189
+ // (e.g. MyType<fn() -> u8, fn() -> u8>
190
+ //
191
+ // We only care about avoiding recursing
192
+ // directly back to the type we're currentlu
193
+ // processing
194
+ visited. remove ( t) ;
182
195
} ,
183
196
ty:: Closure ( ..) => {
184
197
output. push_str ( "closure" ) ;
0 commit comments