@@ -300,7 +300,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
300
300
}
301
301
302
302
if let ast:: FunctionRetTy :: Ty ( ref ret_ty) = sig. decl . output {
303
- v. visit_ty ( ret_ty) ;
303
+ // In async functions, return types are desugared and redefined
304
+ // as an `impl Trait` existential type. Because of this, to match
305
+ // the definition paths when resolving nested types we need to
306
+ // start walking from the newly-created definition.
307
+ match sig. header . asyncness . node {
308
+ ast:: IsAsync :: Async { return_impl_trait_id, .. } => {
309
+ v. nest_tables ( return_impl_trait_id, |v| v. visit_ty ( ret_ty) )
310
+ }
311
+ _ => v. visit_ty ( ret_ty)
312
+ }
304
313
}
305
314
306
315
// walk the fn body
@@ -369,6 +378,7 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
369
378
& mut self ,
370
379
item : & ' l ast:: Item ,
371
380
decl : & ' l ast:: FnDecl ,
381
+ header : & ' l ast:: FnHeader ,
372
382
ty_params : & ' l ast:: Generics ,
373
383
body : & ' l ast:: Block ,
374
384
) {
@@ -391,7 +401,16 @@ impl<'l, 'tcx> DumpVisitor<'l, 'tcx> {
391
401
// FIXME: Opaque type desugaring prevents us from easily
392
402
// processing trait bounds. See `visit_ty` for more details.
393
403
} else {
394
- v. visit_ty ( & ret_ty) ;
404
+ // In async functions, return types are desugared and redefined
405
+ // as an `impl Trait` existential type. Because of this, to match
406
+ // the definition paths when resolving nested types we need to
407
+ // start walking from the newly-created definition.
408
+ match header. asyncness . node {
409
+ ast:: IsAsync :: Async { return_impl_trait_id, .. } => {
410
+ v. nest_tables ( return_impl_trait_id, |v| v. visit_ty ( ret_ty) )
411
+ }
412
+ _ => v. visit_ty ( ret_ty)
413
+ }
395
414
}
396
415
}
397
416
@@ -1315,8 +1334,8 @@ impl<'l, 'tcx> Visitor<'l> for DumpVisitor<'l, 'tcx> {
1315
1334
) ;
1316
1335
}
1317
1336
}
1318
- Fn ( ref decl, .. , ref ty_params, ref body) => {
1319
- self . process_fn ( item, & decl, ty_params, & body)
1337
+ Fn ( ref decl, ref header , ref ty_params, ref body) => {
1338
+ self . process_fn ( item, & decl, & header , ty_params, & body)
1320
1339
}
1321
1340
Static ( ref typ, _, ref expr) => self . process_static_or_const_item ( item, typ, expr) ,
1322
1341
Const ( ref typ, ref expr) => self . process_static_or_const_item ( item, & typ, & expr) ,
0 commit comments