@@ -422,7 +422,18 @@ impl Printer for SymbolPath {
422
422
self : PrintCx < ' _ , ' _ , ' tcx , Self > ,
423
423
ty : Ty < ' tcx > ,
424
424
) -> Result < Self :: Type , Self :: Error > {
425
- self . pretty_print_type ( ty)
425
+ match ty. sty {
426
+ // Print all nominal types as paths (unlike `pretty_print_type`).
427
+ ty:: FnDef ( def_id, substs) |
428
+ ty:: Opaque ( def_id, substs) |
429
+ ty:: Projection ( ty:: ProjectionTy { item_def_id : def_id, substs } ) |
430
+ ty:: UnnormalizedProjection ( ty:: ProjectionTy { item_def_id : def_id, substs } ) |
431
+ ty:: Closure ( def_id, ty:: ClosureSubsts { substs } ) |
432
+ ty:: Generator ( def_id, ty:: GeneratorSubsts { substs } , _) => {
433
+ self . print_def_path ( def_id, Some ( substs) , iter:: empty ( ) )
434
+ }
435
+ _ => self . pretty_print_type ( ty) ,
436
+ }
426
437
}
427
438
428
439
fn path_crate (
@@ -437,7 +448,22 @@ impl Printer for SymbolPath {
437
448
self_ty : Ty < ' tcx > ,
438
449
trait_ref : Option < ty:: TraitRef < ' tcx > > ,
439
450
) -> Result < Self :: Path , Self :: Error > {
440
- self . pretty_path_qualified ( self_ty, trait_ref)
451
+ // Similar to `pretty_path_qualified`, but for the other
452
+ // types that are printed as paths (see `print_type` above).
453
+ match self_ty. sty {
454
+ ty:: FnDef ( ..) |
455
+ ty:: Opaque ( ..) |
456
+ ty:: Projection ( _) |
457
+ ty:: UnnormalizedProjection ( _) |
458
+ ty:: Closure ( ..) |
459
+ ty:: Generator ( ..)
460
+ if trait_ref. is_none ( ) =>
461
+ {
462
+ self . print_type ( self_ty)
463
+ }
464
+
465
+ _ => self . pretty_path_qualified ( self_ty, trait_ref)
466
+ }
441
467
}
442
468
443
469
fn path_append_impl < ' gcx , ' tcx > (
0 commit comments