@@ -1717,10 +1717,12 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
1717
1717
} ) . collect :: < Vec < GenericParamDef > > ( ) ;
1718
1718
1719
1719
// (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 ( ) ;
1721
1722
1722
1723
let mut where_predicates = preds. predicates . iter ( )
1723
1724
. flat_map ( |( p, _) | {
1725
+ let mut projection = None ;
1724
1726
let param_idx = ( || {
1725
1727
if let Some ( trait_ref) = p. to_opt_poly_trait_ref ( ) {
1726
1728
if let ty:: Param ( param) = trait_ref. self_ty ( ) . sty {
@@ -1730,8 +1732,9 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
1730
1732
if let ty:: Param ( param) = outlives. skip_binder ( ) . 0 . sty {
1731
1733
return Some ( param. index ) ;
1732
1734
}
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) ;
1735
1738
return Some ( param. index ) ;
1736
1739
}
1737
1740
}
@@ -1751,16 +1754,15 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
1751
1754
. filter ( |b| !b. is_sized_bound ( cx) )
1752
1755
) ;
1753
1756
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
+ {
1760
1762
impl_trait_proj
1761
- . entry ( ( param_idx, trait_did ) )
1763
+ . entry ( param_idx)
1762
1764
. or_default ( )
1763
- . push ( ( name. to_string ( ) , rhs. clone ( ) ) ) ;
1765
+ . push ( ( trait_did , name. to_string ( ) , rhs) ) ;
1764
1766
}
1765
1767
1766
1768
return None ;
@@ -1771,18 +1773,6 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
1771
1773
} )
1772
1774
. collect :: < Vec < _ > > ( ) ;
1773
1775
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
-
1786
1776
// Move `TraitPredicate`s to the front.
1787
1777
for ( _, bounds) in impl_trait. iter_mut ( ) {
1788
1778
bounds. sort_by_key ( |b| if let GenericBound :: TraitBound ( ..) = b {
@@ -1792,7 +1782,25 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics,
1792
1782
} ) ;
1793
1783
}
1794
1784
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
+ }
1796
1804
1797
1805
// Type parameters and have a Sized bound by default unless removed with
1798
1806
// ?Sized. Scan through the predicates and mark any type parameter with
0 commit comments