@@ -182,18 +182,6 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
182182 }
183183
184184 fn visit_fn ( & mut self , fn_kind : FnKind < ' a > , span : Span , _: NodeId ) {
185- let walk_fn_decl = |this : & mut Self ,
186- coroutine_kind : CoroutineKind ,
187- FnDecl { inputs, output } : & ' a FnDecl | {
188- for param in inputs {
189- this. visit_param ( param) ;
190- }
191-
192- let ( return_id, return_span) = coroutine_kind. return_id ( ) ;
193- let return_def = this. create_def ( return_id, kw:: Empty , DefKind :: OpaqueTy , return_span) ;
194- this. with_parent ( return_def, |this| this. visit_fn_ret_ty ( output) ) ;
195- } ;
196-
197185 match fn_kind {
198186 FnKind :: Fn ( _ctxt, _ident, FnSig { header, decl, span : _ } , _vis, generics, body)
199187 if let Some ( coroutine_kind) = header. coroutine_kind =>
@@ -204,7 +192,15 @@ impl<'a, 'b, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'b, 'tcx> {
204192 // For async functions, we need to create their inner defs inside of a
205193 // closure to match their desugared representation. Besides that,
206194 // we must mirror everything that `visit::walk_fn` below does.
207- walk_fn_decl ( self , coroutine_kind, decl) ;
195+ let FnDecl { inputs, output } = & * * decl;
196+ for param in inputs {
197+ self . visit_param ( param) ;
198+ }
199+
200+ let ( return_id, return_span) = coroutine_kind. return_id ( ) ;
201+ let return_def =
202+ self . create_def ( return_id, kw:: Empty , DefKind :: OpaqueTy , return_span) ;
203+ self . with_parent ( return_def, |this| this. visit_fn_ret_ty ( output) ) ;
208204
209205 // If this async fn has no body (i.e. it's an async fn signature in a trait)
210206 // then the closure_def will never be used, and we should avoid generating a
0 commit comments