@@ -468,13 +468,7 @@ fn clean_projection<'tcx>(
468468 def_id : Option < DefId > ,
469469) -> Type {
470470 if cx. tcx . is_impl_trait_in_trait ( ty. skip_binder ( ) . def_id ) {
471- let bounds = cx
472- . tcx
473- . explicit_item_bounds ( ty. skip_binder ( ) . def_id )
474- . iter_instantiated_copied ( cx. tcx , ty. skip_binder ( ) . args )
475- . map ( |( pred, _) | pred)
476- . collect :: < Vec < _ > > ( ) ;
477- return clean_middle_opaque_bounds ( cx, bounds) ;
471+ return clean_middle_opaque_bounds ( cx, ty. skip_binder ( ) . def_id , ty. skip_binder ( ) . args ) ;
478472 }
479473
480474 let trait_ = clean_trait_ref_with_constraints (
@@ -2260,13 +2254,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
22602254 * cx. current_type_aliases . entry ( def_id) . or_insert ( 0 ) += 1 ;
22612255 // Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
22622256 // by looking up the bounds associated with the def_id.
2263- let bounds = cx
2264- . tcx
2265- . explicit_item_bounds ( def_id)
2266- . iter_instantiated_copied ( cx. tcx , args)
2267- . map ( |( bound, _) | bound)
2268- . collect :: < Vec < _ > > ( ) ;
2269- let ty = clean_middle_opaque_bounds ( cx, bounds) ;
2257+ let ty = clean_middle_opaque_bounds ( cx, def_id, args) ;
22702258 if let Some ( count) = cx. current_type_aliases . get_mut ( & def_id) {
22712259 * count -= 1 ;
22722260 if * count == 0 {
@@ -2289,12 +2277,20 @@ pub(crate) fn clean_middle_ty<'tcx>(
22892277
22902278fn clean_middle_opaque_bounds < ' tcx > (
22912279 cx : & mut DocContext < ' tcx > ,
2292- bounds : Vec < ty:: Clause < ' tcx > > ,
2280+ impl_trait_def_id : DefId ,
2281+ args : ty:: GenericArgsRef < ' tcx > ,
22932282) -> Type {
22942283 let mut has_sized = false ;
2284+
2285+ let bounds: Vec < _ > = cx
2286+ . tcx
2287+ . explicit_item_bounds ( impl_trait_def_id)
2288+ . iter_instantiated_copied ( cx. tcx , args)
2289+ . collect ( ) ;
2290+
22952291 let mut bounds = bounds
22962292 . iter ( )
2297- . filter_map ( |bound| {
2293+ . filter_map ( |( bound, _ ) | {
22982294 let bound_predicate = bound. kind ( ) ;
22992295 let trait_ref = match bound_predicate. skip_binder ( ) {
23002296 ty:: ClauseKind :: Trait ( tr) => bound_predicate. rebind ( tr. trait_ref ) ,
@@ -2313,7 +2309,7 @@ fn clean_middle_opaque_bounds<'tcx>(
23132309
23142310 let bindings: ThinVec < _ > = bounds
23152311 . iter ( )
2316- . filter_map ( |bound| {
2312+ . filter_map ( |( bound, _ ) | {
23172313 if let ty:: ClauseKind :: Projection ( proj) = bound. kind ( ) . skip_binder ( ) {
23182314 if proj. projection_term . trait_ref ( cx. tcx ) == trait_ref. skip_binder ( ) {
23192315 Some ( AssocItemConstraint {
@@ -2353,6 +2349,10 @@ fn clean_middle_opaque_bounds<'tcx>(
23532349 bounds. insert ( 0 , GenericBound :: sized ( cx) ) ;
23542350 }
23552351
2352+ if let Some ( args) = cx. tcx . rendered_precise_capturing_args ( impl_trait_def_id) {
2353+ bounds. push ( GenericBound :: Use ( args. to_vec ( ) ) ) ;
2354+ }
2355+
23562356 ImplTrait ( bounds)
23572357}
23582358
0 commit comments