@@ -180,7 +180,7 @@ impl Clean<Type> for (ty::TraitRef<'_>, &[TypeBinding]) {
180
180
181
181
debug ! ( "ty::TraitRef\n subst: {:?}\n " , trait_ref. substs) ;
182
182
183
- ResolvedPath { path, param_names : None , did : trait_ref. def_id , is_generic : false }
183
+ ResolvedPath { path, did : trait_ref. def_id , is_generic : false }
184
184
}
185
185
}
186
186
@@ -330,6 +330,7 @@ impl Clean<WherePredicate> for hir::WherePredicate<'_> {
330
330
hir:: WherePredicate :: BoundPredicate ( ref wbp) => WherePredicate :: BoundPredicate {
331
331
ty : wbp. bounded_ty . clean ( cx) ,
332
332
bounds : wbp. bounds . clean ( cx) ,
333
+ bound_params : wbp. bound_generic_params . into_iter ( ) . map ( |x| x. clean ( cx) ) . collect ( ) ,
333
334
} ,
334
335
335
336
hir:: WherePredicate :: RegionPredicate ( ref wrp) => WherePredicate :: RegionPredicate {
@@ -370,6 +371,7 @@ impl<'a> Clean<WherePredicate> for ty::PolyTraitPredicate<'a> {
370
371
WherePredicate :: BoundPredicate {
371
372
ty : poly_trait_ref. skip_binder ( ) . self_ty ( ) . clean ( cx) ,
372
373
bounds : vec ! [ poly_trait_ref. clean( cx) ] ,
374
+ bound_params : Vec :: new ( ) ,
373
375
}
374
376
}
375
377
}
@@ -402,6 +404,7 @@ impl<'tcx> Clean<Option<WherePredicate>> for ty::OutlivesPredicate<Ty<'tcx>, ty:
402
404
Some ( WherePredicate :: BoundPredicate {
403
405
ty : ty. clean ( cx) ,
404
406
bounds : vec ! [ GenericBound :: Outlives ( lt. clean( cx) . expect( "failed to clean lifetimes" ) ) ] ,
407
+ bound_params : Vec :: new ( ) ,
405
408
} )
406
409
}
407
410
}
@@ -567,7 +570,9 @@ impl Clean<Generics> for hir::Generics<'_> {
567
570
// to where predicates when such cases occur.
568
571
for where_pred in & mut generics. where_predicates {
569
572
match * where_pred {
570
- WherePredicate :: BoundPredicate { ty : Generic ( ref name) , ref mut bounds } => {
573
+ WherePredicate :: BoundPredicate {
574
+ ty : Generic ( ref name) , ref mut bounds, ..
575
+ } => {
571
576
if bounds. is_empty ( ) {
572
577
for param in & mut generics. params {
573
578
match param. kind {
@@ -721,7 +726,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
721
726
// handled in cleaning associated types
722
727
let mut sized_params = FxHashSet :: default ( ) ;
723
728
where_predicates. retain ( |pred| match * pred {
724
- WP :: BoundPredicate { ty : Generic ( ref g) , ref bounds } => {
729
+ WP :: BoundPredicate { ty : Generic ( ref g) , ref bounds, .. } => {
725
730
if bounds. iter ( ) . any ( |b| b. is_sized_bound ( cx) ) {
726
731
sized_params. insert ( * g) ;
727
732
false
@@ -741,6 +746,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
741
746
where_predicates. push ( WP :: BoundPredicate {
742
747
ty : Type :: Generic ( tp. name ) ,
743
748
bounds : vec ! [ GenericBound :: maybe_sized( cx) ] ,
749
+ bound_params : Vec :: new ( ) ,
744
750
} )
745
751
}
746
752
}
@@ -1117,6 +1123,7 @@ impl Clean<Item> for ty::AssocItem {
1117
1123
WherePredicate :: BoundPredicate {
1118
1124
ty : QPath { ref name, ref self_type, ref trait_, .. } ,
1119
1125
ref bounds,
1126
+ ..
1120
1127
} => ( name, self_type, trait_, bounds) ,
1121
1128
_ => return None ,
1122
1129
} ;
@@ -1371,24 +1378,9 @@ impl Clean<Type> for hir::Ty<'_> {
1371
1378
}
1372
1379
TyKind :: Path ( _) => clean_qpath ( & self , cx) ,
1373
1380
TyKind :: TraitObject ( ref bounds, ref lifetime, _) => {
1374
- match bounds[ 0 ] . clean ( cx) . trait_ {
1375
- ResolvedPath { path, param_names : None , did, is_generic } => {
1376
- let mut bounds: Vec < self :: GenericBound > = bounds[ 1 ..]
1377
- . iter ( )
1378
- . map ( |bound| {
1379
- self :: GenericBound :: TraitBound (
1380
- bound. clean ( cx) ,
1381
- hir:: TraitBoundModifier :: None ,
1382
- )
1383
- } )
1384
- . collect ( ) ;
1385
- if !lifetime. is_elided ( ) {
1386
- bounds. push ( self :: GenericBound :: Outlives ( lifetime. clean ( cx) ) ) ;
1387
- }
1388
- ResolvedPath { path, param_names : Some ( bounds) , did, is_generic }
1389
- }
1390
- _ => Infer , // shouldn't happen
1391
- }
1381
+ let bounds = bounds. iter ( ) . map ( |bound| bound. clean ( cx) ) . collect ( ) ;
1382
+ let lifetime = if !lifetime. is_elided ( ) { Some ( lifetime. clean ( cx) ) } else { None } ;
1383
+ DynTrait ( bounds, lifetime)
1392
1384
}
1393
1385
TyKind :: BareFn ( ref barefn) => BareFunction ( box barefn. clean ( cx) ) ,
1394
1386
TyKind :: Infer | TyKind :: Err => Infer ,
@@ -1471,7 +1463,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1471
1463
} ;
1472
1464
inline:: record_extern_fqn ( cx, did, kind) ;
1473
1465
let path = external_path ( cx, cx. tcx . item_name ( did) , None , false , vec ! [ ] , substs) ;
1474
- ResolvedPath { path, param_names : None , did, is_generic : false }
1466
+ ResolvedPath { path, did, is_generic : false }
1475
1467
}
1476
1468
ty:: Foreign ( did) => {
1477
1469
inline:: record_extern_fqn ( cx, did, ItemType :: ForeignType ) ;
@@ -1483,7 +1475,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1483
1475
vec ! [ ] ,
1484
1476
InternalSubsts :: empty ( ) ,
1485
1477
) ;
1486
- ResolvedPath { path, param_names : None , did, is_generic : false }
1478
+ ResolvedPath { path, did, is_generic : false }
1487
1479
}
1488
1480
ty:: Dynamic ( ref obj, ref reg) => {
1489
1481
// HACK: pick the first `did` as the `did` of the trait object. Someone
@@ -1501,28 +1493,19 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1501
1493
1502
1494
inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1503
1495
1504
- let mut param_names = vec ! [ ] ;
1505
- if let Some ( b) = reg. clean ( cx) {
1506
- param_names. push ( GenericBound :: Outlives ( b) ) ;
1507
- }
1496
+ let lifetime = reg. clean ( cx) ;
1497
+ let mut bounds = vec ! [ ] ;
1498
+
1508
1499
for did in dids {
1509
1500
let empty = cx. tcx . intern_substs ( & [ ] ) ;
1510
1501
let path =
1511
1502
external_path ( cx, cx. tcx . item_name ( did) , Some ( did) , false , vec ! [ ] , empty) ;
1512
1503
inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1513
- let bound = GenericBound :: TraitBound (
1514
- PolyTrait {
1515
- trait_ : ResolvedPath {
1516
- path,
1517
- param_names : None ,
1518
- did,
1519
- is_generic : false ,
1520
- } ,
1521
- generic_params : Vec :: new ( ) ,
1522
- } ,
1523
- hir:: TraitBoundModifier :: None ,
1524
- ) ;
1525
- param_names. push ( bound) ;
1504
+ let bound = PolyTrait {
1505
+ trait_ : ResolvedPath { path, did, is_generic : false } ,
1506
+ generic_params : Vec :: new ( ) ,
1507
+ } ;
1508
+ bounds. push ( bound) ;
1526
1509
}
1527
1510
1528
1511
let mut bindings = vec ! [ ] ;
@@ -1535,7 +1518,15 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1535
1518
1536
1519
let path =
1537
1520
external_path ( cx, cx. tcx . item_name ( did) , Some ( did) , false , bindings, substs) ;
1538
- ResolvedPath { path, param_names : Some ( param_names) , did, is_generic : false }
1521
+ bounds. insert (
1522
+ 0 ,
1523
+ PolyTrait {
1524
+ trait_ : ResolvedPath { path, did, is_generic : false } ,
1525
+ generic_params : Vec :: new ( ) ,
1526
+ } ,
1527
+ ) ;
1528
+
1529
+ DynTrait ( bounds, lifetime)
1539
1530
}
1540
1531
ty:: Tuple ( ref t) => {
1541
1532
Tuple ( t. iter ( ) . map ( |t| t. expect_ty ( ) ) . collect :: < Vec < _ > > ( ) . clean ( cx) )
@@ -2239,14 +2230,9 @@ impl From<GenericBound> for SimpleBound {
2239
2230
match bound. clone ( ) {
2240
2231
GenericBound :: Outlives ( l) => SimpleBound :: Outlives ( l) ,
2241
2232
GenericBound :: TraitBound ( t, mod_) => match t. trait_ {
2242
- Type :: ResolvedPath { path, param_names, .. } => SimpleBound :: TraitBound (
2243
- path. segments ,
2244
- param_names. map_or_else ( Vec :: new, |v| {
2245
- v. iter ( ) . map ( |p| SimpleBound :: from ( p. clone ( ) ) ) . collect ( )
2246
- } ) ,
2247
- t. generic_params ,
2248
- mod_,
2249
- ) ,
2233
+ Type :: ResolvedPath { path, .. } => {
2234
+ SimpleBound :: TraitBound ( path. segments , Vec :: new ( ) , t. generic_params , mod_)
2235
+ }
2250
2236
_ => panic ! ( "Unexpected bound {:?}" , bound) ,
2251
2237
} ,
2252
2238
}
0 commit comments