@@ -1717,10 +1717,12 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17171717 } ) . collect :: < Vec < GenericParamDef > > ( ) ;
17181718
17191719 // (param index, def id of trait) -> (name, type)
1720- let mut impl_trait_proj = FxHashMap :: < ( u32 , DefId ) , Vec < ( String , Type ) > > :: default ( ) ;
1720+ let mut impl_trait_proj =
1721+ FxHashMap :: < u32 , Vec < ( DefId , String , Ty < ' tcx > ) > > :: default ( ) ;
17211722
17221723 let mut where_predicates = preds. predicates . iter ( )
17231724 . flat_map ( |( p, _) | {
1725+ let mut projection = None ;
17241726 let param_idx = ( || {
17251727 if let Some ( trait_ref) = p. to_opt_poly_trait_ref ( ) {
17261728 if let ty:: Param ( param) = trait_ref. self_ty ( ) . sty {
@@ -1730,8 +1732,9 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17301732 if let ty:: Param ( param) = outlives. skip_binder ( ) . 0 . sty {
17311733 return Some ( param. index ) ;
17321734 }
1733- } else if let ty:: Predicate :: Projection ( proj) = p {
1734- if let ty:: Param ( param) = proj. skip_binder ( ) . projection_ty . self_ty ( ) . sty {
1735+ } else if let ty:: Predicate :: Projection ( p) = p {
1736+ if let ty:: Param ( param) = p. skip_binder ( ) . projection_ty . self_ty ( ) . sty {
1737+ projection = Some ( p) ;
17351738 return Some ( param. index ) ;
17361739 }
17371740 }
@@ -1751,16 +1754,15 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17511754 . filter ( |b| !b. is_sized_bound ( cx) )
17521755 ) ;
17531756
1754- let proj = match & p {
1755- WherePredicate :: EqPredicate { lhs, rhs } => Some ( ( lhs, rhs) )
1756- . and_then ( |( lhs, rhs) | Some ( ( lhs. projection ( ) ?, rhs) ) ) ,
1757- _ => None ,
1758- } ;
1759- if let Some ( ( ( _, trait_did, name) , rhs) ) = proj {
1757+ let proj = projection
1758+ . map ( |p| ( p. skip_binder ( ) . projection_ty . clean ( cx) , p. skip_binder ( ) . ty ) ) ;
1759+ if let Some ( ( ( _, trait_did, name) , rhs) ) =
1760+ proj. as_ref ( ) . and_then ( |( lhs, rhs) | Some ( ( lhs. projection ( ) ?, rhs) ) )
1761+ {
17601762 impl_trait_proj
1761- . entry ( ( param_idx, trait_did ) )
1763+ . entry ( param_idx)
17621764 . or_default ( )
1763- . push ( ( name. to_string ( ) , rhs. clone ( ) ) ) ;
1765+ . push ( ( trait_did , name. to_string ( ) , rhs) ) ;
17641766 }
17651767
17661768 return None ;
@@ -1771,18 +1773,6 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17711773 } )
17721774 . collect :: < Vec < _ > > ( ) ;
17731775
1774- for ( ( param_idx, trait_did) , bounds) in impl_trait_proj {
1775- for ( name, rhs) in bounds {
1776- simplify:: merge_bounds (
1777- cx,
1778- impl_trait. get_mut ( & param_idx. into ( ) ) . unwrap ( ) ,
1779- trait_did,
1780- & name,
1781- & rhs,
1782- ) ;
1783- }
1784- }
1785-
17861776 // Move `TraitPredicate`s to the front.
17871777 for ( _, bounds) in impl_trait. iter_mut ( ) {
17881778 bounds. sort_by_key ( |b| if let GenericBound :: TraitBound ( ..) = b {
@@ -1792,7 +1782,25 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
17921782 } ) ;
17931783 }
17941784
1795- cx. impl_trait_bounds . borrow_mut ( ) . extend ( impl_trait) ;
1785+ for ( param, mut bounds) in impl_trait {
1786+ if let crate :: core:: ImplTraitParam :: ParamIndex ( idx) = param {
1787+ if let Some ( proj) = impl_trait_proj. remove ( & idx) {
1788+ for ( trait_did, name, rhs) in proj {
1789+ simplify:: merge_bounds (
1790+ cx,
1791+ & mut bounds,
1792+ trait_did,
1793+ & name,
1794+ & rhs. clean ( cx) ,
1795+ ) ;
1796+ }
1797+ }
1798+ } else {
1799+ unreachable ! ( ) ;
1800+ }
1801+
1802+ cx. impl_trait_bounds . borrow_mut ( ) . insert ( param, bounds) ;
1803+ }
17961804
17971805 // Type parameters and have a Sized bound by default unless removed with
17981806 // ?Sized. Scan through the predicates and mark any type parameter with
0 commit comments