@@ -292,8 +292,9 @@ fn clean_where_predicate<'tcx>(
292292 } ,
293293
294294 hir:: WherePredicate :: EqPredicate ( ref wrp) => WherePredicate :: EqPredicate {
295- lhs : clean_ty ( wrp. lhs_ty , cx) ,
296- rhs : clean_ty ( wrp. rhs_ty , cx) . into ( ) ,
295+ lhs : Box :: new ( clean_ty ( wrp. lhs_ty , cx) ) ,
296+ rhs : Box :: new ( clean_ty ( wrp. rhs_ty , cx) . into ( ) ) ,
297+ bound_params : Vec :: new ( ) ,
297298 } ,
298299 } )
299300}
@@ -309,7 +310,9 @@ pub(crate) fn clean_predicate<'tcx>(
309310 }
310311 ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred) ,
311312 ty:: PredicateKind :: TypeOutlives ( pred) => clean_type_outlives_predicate ( pred, cx) ,
312- ty:: PredicateKind :: Projection ( pred) => Some ( clean_projection_predicate ( pred, cx) ) ,
313+ ty:: PredicateKind :: Projection ( pred) => {
314+ Some ( clean_projection_predicate ( bound_predicate. rebind ( pred) , cx) )
315+ }
313316 ty:: PredicateKind :: ConstEvaluatable ( ..) => None ,
314317 ty:: PredicateKind :: WellFormed ( ..) => None ,
315318
@@ -387,13 +390,25 @@ fn clean_hir_term<'tcx>(term: &hir::Term<'tcx>, cx: &mut DocContext<'tcx>) -> Te
387390}
388391
389392fn clean_projection_predicate < ' tcx > (
390- pred : ty:: ProjectionPredicate < ' tcx > ,
393+ pred : ty:: Binder < ' tcx , ty :: ProjectionPredicate < ' tcx > > ,
391394 cx : & mut DocContext < ' tcx > ,
392395) -> WherePredicate {
393- let ty:: ProjectionPredicate { projection_ty, term } = pred;
396+ let late_bound_regions = cx
397+ . tcx
398+ . collect_referenced_late_bound_regions ( & pred)
399+ . into_iter ( )
400+ . filter_map ( |br| match br {
401+ ty:: BrNamed ( _, name) if name != kw:: UnderscoreLifetime => Some ( Lifetime ( name) ) ,
402+ _ => None ,
403+ } )
404+ . collect ( ) ;
405+
406+ let ty:: ProjectionPredicate { projection_ty, term } = pred. skip_binder ( ) ;
407+
394408 WherePredicate :: EqPredicate {
395- lhs : clean_projection ( projection_ty, cx, None ) ,
396- rhs : clean_middle_term ( term, cx) ,
409+ lhs : Box :: new ( clean_projection ( projection_ty, cx, None ) ) ,
410+ rhs : Box :: new ( clean_middle_term ( term, cx) ) ,
411+ bound_params : late_bound_regions,
397412 }
398413}
399414
@@ -655,8 +670,9 @@ fn clean_ty_generics<'tcx>(
655670 } )
656671 . collect :: < Vec < GenericParamDef > > ( ) ;
657672
658- // param index -> [(DefId of trait, associated type name and generics, type)]
659- let mut impl_trait_proj = FxHashMap :: < u32 , Vec < ( DefId , PathSegment , Ty < ' _ > ) > > :: default ( ) ;
673+ // param index -> [(trait DefId, associated type name & generics, type, higher-ranked params)]
674+ let mut impl_trait_proj =
675+ FxHashMap :: < u32 , Vec < ( DefId , PathSegment , Ty < ' _ > , Vec < GenericParamDef > ) > > :: default ( ) ;
660676
661677 let where_predicates = preds
662678 . predicates
@@ -715,6 +731,14 @@ fn clean_ty_generics<'tcx>(
715731 trait_did,
716732 name,
717733 rhs. ty ( ) . unwrap ( ) ,
734+ p. get_bound_params ( )
735+ . into_iter ( )
736+ . flatten ( )
737+ . map ( |param| GenericParamDef {
738+ name : param. 0 ,
739+ kind : GenericParamDefKind :: Lifetime { outlives : Vec :: new ( ) } ,
740+ } )
741+ . collect ( ) ,
718742 ) ) ;
719743 }
720744
@@ -730,15 +754,19 @@ fn clean_ty_generics<'tcx>(
730754 // Move trait bounds to the front.
731755 bounds. sort_by_key ( |b| !matches ! ( b, GenericBound :: TraitBound ( ..) ) ) ;
732756
733- if let crate :: core:: ImplTraitParam :: ParamIndex ( idx) = param {
734- if let Some ( proj) = impl_trait_proj. remove ( & idx) {
735- for ( trait_did, name, rhs) in proj {
736- let rhs = clean_middle_ty ( rhs, cx, None ) ;
737- simplify:: merge_bounds ( cx, & mut bounds, trait_did, name, & Term :: Type ( rhs) ) ;
738- }
757+ let crate :: core:: ImplTraitParam :: ParamIndex ( idx) = param else { unreachable ! ( ) } ;
758+ if let Some ( proj) = impl_trait_proj. remove ( & idx) {
759+ for ( trait_did, name, rhs, bound_params) in proj {
760+ let rhs = clean_middle_ty ( rhs, cx, None ) ;
761+ simplify:: merge_bounds (
762+ cx,
763+ & mut bounds,
764+ bound_params,
765+ trait_did,
766+ name,
767+ & Term :: Type ( rhs) ,
768+ ) ;
739769 }
740- } else {
741- unreachable ! ( ) ;
742770 }
743771
744772 cx. impl_trait_bounds . insert ( param, bounds) ;
0 commit comments