@@ -292,8 +292,9 @@ fn clean_where_predicate<'tcx>(
292
292
} ,
293
293
294
294
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 ( ) ,
297
298
} ,
298
299
} )
299
300
}
@@ -309,7 +310,9 @@ pub(crate) fn clean_predicate<'tcx>(
309
310
}
310
311
ty:: PredicateKind :: RegionOutlives ( pred) => clean_region_outlives_predicate ( pred) ,
311
312
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
+ }
313
316
ty:: PredicateKind :: ConstEvaluatable ( ..) => None ,
314
317
ty:: PredicateKind :: WellFormed ( ..) => None ,
315
318
@@ -387,13 +390,25 @@ fn clean_hir_term<'tcx>(term: &hir::Term<'tcx>, cx: &mut DocContext<'tcx>) -> Te
387
390
}
388
391
389
392
fn clean_projection_predicate < ' tcx > (
390
- pred : ty:: ProjectionPredicate < ' tcx > ,
393
+ pred : ty:: Binder < ' tcx , ty :: ProjectionPredicate < ' tcx > > ,
391
394
cx : & mut DocContext < ' tcx > ,
392
395
) -> 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
+
394
408
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,
397
412
}
398
413
}
399
414
@@ -655,8 +670,9 @@ fn clean_ty_generics<'tcx>(
655
670
} )
656
671
. collect :: < Vec < GenericParamDef > > ( ) ;
657
672
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 ( ) ;
660
676
661
677
let where_predicates = preds
662
678
. predicates
@@ -715,6 +731,14 @@ fn clean_ty_generics<'tcx>(
715
731
trait_did,
716
732
name,
717
733
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 ( ) ,
718
742
) ) ;
719
743
}
720
744
@@ -730,15 +754,19 @@ fn clean_ty_generics<'tcx>(
730
754
// Move trait bounds to the front.
731
755
bounds. sort_by_key ( |b| !matches ! ( b, GenericBound :: TraitBound ( ..) ) ) ;
732
756
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
+ ) ;
739
769
}
740
- } else {
741
- unreachable ! ( ) ;
742
770
}
743
771
744
772
cx. impl_trait_bounds . insert ( param, bounds) ;
0 commit comments