@@ -468,13 +468,7 @@ fn clean_projection<'tcx>(
468
468
def_id : Option < DefId > ,
469
469
) -> Type {
470
470
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 ) ;
478
472
}
479
473
480
474
let trait_ = clean_trait_ref_with_constraints (
@@ -2260,13 +2254,7 @@ pub(crate) fn clean_middle_ty<'tcx>(
2260
2254
* cx. current_type_aliases . entry ( def_id) . or_insert ( 0 ) += 1 ;
2261
2255
// Grab the "TraitA + TraitB" from `impl TraitA + TraitB`,
2262
2256
// 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) ;
2270
2258
if let Some ( count) = cx. current_type_aliases . get_mut ( & def_id) {
2271
2259
* count -= 1 ;
2272
2260
if * count == 0 {
@@ -2289,12 +2277,20 @@ pub(crate) fn clean_middle_ty<'tcx>(
2289
2277
2290
2278
fn clean_middle_opaque_bounds < ' tcx > (
2291
2279
cx : & mut DocContext < ' tcx > ,
2292
- bounds : Vec < ty:: Clause < ' tcx > > ,
2280
+ impl_trait_def_id : DefId ,
2281
+ args : ty:: GenericArgsRef < ' tcx > ,
2293
2282
) -> Type {
2294
2283
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
+
2295
2291
let mut bounds = bounds
2296
2292
. iter ( )
2297
- . filter_map ( |bound| {
2293
+ . filter_map ( |( bound, _ ) | {
2298
2294
let bound_predicate = bound. kind ( ) ;
2299
2295
let trait_ref = match bound_predicate. skip_binder ( ) {
2300
2296
ty:: ClauseKind :: Trait ( tr) => bound_predicate. rebind ( tr. trait_ref ) ,
@@ -2313,7 +2309,7 @@ fn clean_middle_opaque_bounds<'tcx>(
2313
2309
2314
2310
let bindings: ThinVec < _ > = bounds
2315
2311
. iter ( )
2316
- . filter_map ( |bound| {
2312
+ . filter_map ( |( bound, _ ) | {
2317
2313
if let ty:: ClauseKind :: Projection ( proj) = bound. kind ( ) . skip_binder ( ) {
2318
2314
if proj. projection_term . trait_ref ( cx. tcx ) == trait_ref. skip_binder ( ) {
2319
2315
Some ( AssocItemConstraint {
@@ -2353,6 +2349,10 @@ fn clean_middle_opaque_bounds<'tcx>(
2353
2349
bounds. insert ( 0 , GenericBound :: sized ( cx) ) ;
2354
2350
}
2355
2351
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
+
2356
2356
ImplTrait ( bounds)
2357
2357
}
2358
2358
0 commit comments