@@ -9,6 +9,7 @@ use std::borrow::Cow;
99use std:: fmt;
1010
1111use rustc:: hir:: def_id:: DefId ;
12+ use rustc:: util:: nodemap:: FxHashSet ;
1213use rustc_target:: spec:: abi:: Abi ;
1314use rustc:: hir;
1415
@@ -106,8 +107,10 @@ impl<'a, T: fmt::Display> fmt::Display for CommaSep<'a, T> {
106107
107108impl < ' a > fmt:: Display for GenericBounds < ' a > {
108109 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
110+ let mut bounds_dup = FxHashSet :: default ( ) ;
109111 let & GenericBounds ( bounds) = self ;
110- for ( i, bound) in bounds. iter ( ) . enumerate ( ) {
112+
113+ for ( i, bound) in bounds. iter ( ) . filter ( |b| bounds_dup. insert ( b. to_string ( ) ) ) . enumerate ( ) {
111114 if i > 0 {
112115 f. write_str ( " + " ) ?;
113116 }
@@ -205,16 +208,13 @@ impl<'a> fmt::Display for WhereClause<'a> {
205208 clause. push_str ( & format ! ( "{}: {}" , ty, GenericBounds ( bounds) ) ) ;
206209 }
207210 }
208- & clean:: WherePredicate :: RegionPredicate { ref lifetime,
209- ref bounds } => {
210- clause. push_str ( & format ! ( "{}: " , lifetime) ) ;
211- for ( i, lifetime) in bounds. iter ( ) . enumerate ( ) {
212- if i > 0 {
213- clause. push_str ( " + " ) ;
214- }
215-
216- clause. push_str ( & lifetime. to_string ( ) ) ;
217- }
211+ & clean:: WherePredicate :: RegionPredicate { ref lifetime, ref bounds } => {
212+ clause. push_str ( & format ! ( "{}: {}" ,
213+ lifetime,
214+ bounds. iter( )
215+ . map( |b| b. to_string( ) )
216+ . collect:: <Vec <_>>( )
217+ . join( " + " ) ) ) ;
218218 }
219219 & clean:: WherePredicate :: EqPredicate { ref lhs, ref rhs } => {
220220 if f. alternate ( ) {
0 commit comments