@@ -428,17 +428,19 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
428
428
ty_enum( did, ref substs) | ty_struct( did, ref substs) => {
429
429
let base = ty:: item_path_str ( cx, did) ;
430
430
let generics = ty:: lookup_item_type ( cx, did) . generics ;
431
- parameterized ( cx, base. as_slice ( ) , substs, & generics)
431
+ parameterized ( cx, base. as_slice ( ) , substs, & generics, did )
432
432
}
433
433
ty_trait( box ty:: TyTrait {
434
434
ref principal, ref bounds
435
435
} ) => {
436
436
let base = ty:: item_path_str ( cx, principal. def_id ) ;
437
437
let trait_def = ty:: lookup_trait_def ( cx, principal. def_id ) ;
438
+ let did = trait_def. trait_ref . def_id ;
438
439
let ty = parameterized ( cx, base. as_slice ( ) ,
439
- & principal. substs , & trait_def. generics ) ;
440
+ & principal. substs , & trait_def. generics ,
441
+ did) ;
440
442
let bound_str = bounds. user_string ( cx) ;
441
- let bound_sep = if bound_str. is_empty ( ) { "" } else { "+ " } ;
443
+ let bound_sep = if bound_str. is_empty ( ) { "" } else { " + " } ;
442
444
format ! ( "{}{}{}" ,
443
445
ty,
444
446
bound_sep,
@@ -484,7 +486,8 @@ pub fn explicit_self_category_to_str(category: &ty::ExplicitSelfCategory)
484
486
pub fn parameterized < ' tcx > ( cx : & ctxt < ' tcx > ,
485
487
base : & str ,
486
488
substs : & subst:: Substs < ' tcx > ,
487
- generics : & ty:: Generics < ' tcx > )
489
+ generics : & ty:: Generics < ' tcx > ,
490
+ did : ast:: DefId )
488
491
-> String
489
492
{
490
493
if cx. sess . verbose ( ) {
@@ -537,7 +540,12 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
537
540
strs. push ( ty_to_string ( cx, * t) )
538
541
}
539
542
540
- if strs. len ( ) > 0 u {
543
+ if cx. lang_items . fn_trait_kind ( did) . is_some ( ) {
544
+ format ! ( "{}({}){}" ,
545
+ base,
546
+ strs[ 0 ] [ 1 .. strs[ 0 ] . len( ) - ( strs[ 0 ] . ends_with( ",)" ) as uint+1 ) ] ,
547
+ if & * strs[ 1 ] == "()" { String :: new( ) } else { format!( " -> {}" , strs[ 1 ] ) } )
548
+ } else if strs. len ( ) > 0 {
541
549
format ! ( "{}<{}>" , base, strs. connect( ", " ) )
542
550
} else {
543
551
format ! ( "{}" , base)
@@ -743,7 +751,7 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
743
751
let trait_def = ty:: lookup_trait_def ( tcx, self . def_id ) ;
744
752
format ! ( "<{} : {}>" ,
745
753
self . substs. self_ty( ) . repr( tcx) ,
746
- parameterized( tcx, base. as_slice( ) , & self . substs, & trait_def. generics) )
754
+ parameterized( tcx, base. as_slice( ) , & self . substs, & trait_def. generics, self . def_id ) )
747
755
}
748
756
}
749
757
@@ -1116,7 +1124,7 @@ impl<'tcx> UserString<'tcx> for ty::ParamBounds<'tcx> {
1116
1124
for n in self . trait_bounds . iter ( ) {
1117
1125
result. push ( n. user_string ( tcx) ) ;
1118
1126
}
1119
- result. connect ( "+ " )
1127
+ result. connect ( " + " )
1120
1128
}
1121
1129
}
1122
1130
@@ -1189,7 +1197,8 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> {
1189
1197
} ;
1190
1198
1191
1199
let trait_def = ty:: lookup_trait_def ( tcx, self . def_id ) ;
1192
- parameterized ( tcx, base. as_slice ( ) , & trait_ref. substs , & trait_def. generics )
1200
+ let did = trait_def. trait_ref . def_id ;
1201
+ parameterized ( tcx, base. as_slice ( ) , & trait_ref. substs , & trait_def. generics , did)
1193
1202
}
1194
1203
}
1195
1204
0 commit comments