@@ -31,24 +31,6 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
3131 output : & mut String ,
3232 visited : & mut FxHashSet < Ty < ' tcx > > ) {
3333
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-
5234 // When targeting MSVC, emit C++ style type names for compatibility with
5335 // .natvis visualizers (and perhaps other existing native debuggers?)
5436 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>,
141123 }
142124 } ,
143125 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+
144145 let sig = t. fn_sig ( cx. tcx ) ;
145146 if sig. unsafety ( ) == hir:: Unsafety :: Unsafe {
146147 output. push_str ( "unsafe " ) ;
@@ -179,6 +180,18 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
179180 output. push_str ( " -> " ) ;
180181 push_debuginfo_type_name ( cx, sig. output ( ) , true , output, visited) ;
181182 }
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) ;
182195 } ,
183196 ty:: Closure ( ..) => {
184197 output. push_str ( "closure" ) ;
0 commit comments