@@ -428,17 +428,19 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
428428 ty_enum( did, ref substs) | ty_struct( did, ref substs) => {
429429 let base = ty:: item_path_str ( cx, did) ;
430430 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 )
432432 }
433433 ty_trait( box ty:: TyTrait {
434434 ref principal, ref bounds
435435 } ) => {
436436 let base = ty:: item_path_str ( cx, principal. def_id ) ;
437437 let trait_def = ty:: lookup_trait_def ( cx, principal. def_id ) ;
438+ let did = trait_def. trait_ref . def_id ;
438439 let ty = parameterized ( cx, base. as_slice ( ) ,
439- & principal. substs , & trait_def. generics ) ;
440+ & principal. substs , & trait_def. generics ,
441+ did) ;
440442 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 { " + " } ;
442444 format ! ( "{}{}{}" ,
443445 ty,
444446 bound_sep,
@@ -484,7 +486,8 @@ pub fn explicit_self_category_to_str(category: &ty::ExplicitSelfCategory)
484486pub fn parameterized < ' tcx > ( cx : & ctxt < ' tcx > ,
485487 base : & str ,
486488 substs : & subst:: Substs < ' tcx > ,
487- generics : & ty:: Generics < ' tcx > )
489+ generics : & ty:: Generics < ' tcx > ,
490+ did : ast:: DefId )
488491 -> String
489492{
490493 if cx. sess . verbose ( ) {
@@ -537,7 +540,12 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
537540 strs. push ( ty_to_string ( cx, * t) )
538541 }
539542
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 {
541549 format ! ( "{}<{}>" , base, strs. connect( ", " ) )
542550 } else {
543551 format ! ( "{}" , base)
@@ -743,7 +751,7 @@ impl<'tcx> Repr<'tcx> for ty::TraitRef<'tcx> {
743751 let trait_def = ty:: lookup_trait_def ( tcx, self . def_id ) ;
744752 format ! ( "<{} : {}>" ,
745753 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 ) )
747755 }
748756}
749757
@@ -1116,7 +1124,7 @@ impl<'tcx> UserString<'tcx> for ty::ParamBounds<'tcx> {
11161124 for n in self . trait_bounds . iter ( ) {
11171125 result. push ( n. user_string ( tcx) ) ;
11181126 }
1119- result. connect ( "+ " )
1127+ result. connect ( " + " )
11201128 }
11211129}
11221130
@@ -1189,7 +1197,8 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> {
11891197 } ;
11901198
11911199 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)
11931202 }
11941203}
11951204
0 commit comments