@@ -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
@@ -1378,30 +1378,9 @@ impl Clean<Type> for hir::Ty<'_> {
1378
1378
}
1379
1379
TyKind :: Path ( _) => clean_qpath ( & self , cx) ,
1380
1380
TyKind :: TraitObject ( ref bounds, ref lifetime, _) => {
1381
- let cleaned = bounds[ 0 ] . clean ( cx) ;
1382
- match cleaned. trait_ {
1383
- ResolvedPath { path, param_names : None , did, is_generic, .. } => {
1384
- let mut bounds: Vec < self :: GenericBound > = bounds[ 1 ..]
1385
- . iter ( )
1386
- . map ( |bound| {
1387
- self :: GenericBound :: TraitBound (
1388
- bound. clean ( cx) ,
1389
- hir:: TraitBoundModifier :: None ,
1390
- )
1391
- } )
1392
- . collect ( ) ;
1393
- if !lifetime. is_elided ( ) {
1394
- bounds. push ( self :: GenericBound :: Outlives ( lifetime. clean ( cx) ) ) ;
1395
- }
1396
- ResolvedPath {
1397
- path,
1398
- param_names : Some ( ( bounds, cleaned. generic_params ) ) ,
1399
- did,
1400
- is_generic,
1401
- }
1402
- }
1403
- _ => Infer , // shouldn't happen
1404
- }
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)
1405
1384
}
1406
1385
TyKind :: BareFn ( ref barefn) => BareFunction ( box barefn. clean ( cx) ) ,
1407
1386
TyKind :: Infer | TyKind :: Err => Infer ,
@@ -1484,7 +1463,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1484
1463
} ;
1485
1464
inline:: record_extern_fqn ( cx, did, kind) ;
1486
1465
let path = external_path ( cx, cx. tcx . item_name ( did) , None , false , vec ! [ ] , substs) ;
1487
- ResolvedPath { path, param_names : None , did, is_generic : false }
1466
+ ResolvedPath { path, did, is_generic : false }
1488
1467
}
1489
1468
ty:: Foreign ( did) => {
1490
1469
inline:: record_extern_fqn ( cx, did, ItemType :: ForeignType ) ;
@@ -1496,7 +1475,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1496
1475
vec ! [ ] ,
1497
1476
InternalSubsts :: empty ( ) ,
1498
1477
) ;
1499
- ResolvedPath { path, param_names : None , did, is_generic : false }
1478
+ ResolvedPath { path, did, is_generic : false }
1500
1479
}
1501
1480
ty:: Dynamic ( ref obj, ref reg) => {
1502
1481
// HACK: pick the first `did` as the `did` of the trait object. Someone
@@ -1514,28 +1493,19 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1514
1493
1515
1494
inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1516
1495
1517
- let mut param_names = vec ! [ ] ;
1518
- if let Some ( b) = reg. clean ( cx) {
1519
- param_names. push ( GenericBound :: Outlives ( b) ) ;
1520
- }
1496
+ let lifetime = reg. clean ( cx) ;
1497
+ let mut bounds = vec ! [ ] ;
1498
+
1521
1499
for did in dids {
1522
1500
let empty = cx. tcx . intern_substs ( & [ ] ) ;
1523
1501
let path =
1524
1502
external_path ( cx, cx. tcx . item_name ( did) , Some ( did) , false , vec ! [ ] , empty) ;
1525
1503
inline:: record_extern_fqn ( cx, did, ItemType :: Trait ) ;
1526
- let bound = GenericBound :: TraitBound (
1527
- PolyTrait {
1528
- trait_ : ResolvedPath {
1529
- path,
1530
- param_names : None ,
1531
- did,
1532
- is_generic : false ,
1533
- } ,
1534
- generic_params : Vec :: new ( ) ,
1535
- } ,
1536
- hir:: TraitBoundModifier :: None ,
1537
- ) ;
1538
- 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) ;
1539
1509
}
1540
1510
1541
1511
let mut bindings = vec ! [ ] ;
@@ -1548,12 +1518,15 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
1548
1518
1549
1519
let path =
1550
1520
external_path ( cx, cx. tcx . item_name ( did) , Some ( did) , false , bindings, substs) ;
1551
- ResolvedPath {
1552
- path,
1553
- param_names : Some ( ( param_names, vec ! [ ] ) ) ,
1554
- did,
1555
- is_generic : false ,
1556
- }
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)
1557
1530
}
1558
1531
ty:: Tuple ( ref t) => {
1559
1532
Tuple ( t. iter ( ) . map ( |t| t. expect_ty ( ) ) . collect :: < Vec < _ > > ( ) . clean ( cx) )
@@ -2257,14 +2230,9 @@ impl From<GenericBound> for SimpleBound {
2257
2230
match bound. clone ( ) {
2258
2231
GenericBound :: Outlives ( l) => SimpleBound :: Outlives ( l) ,
2259
2232
GenericBound :: TraitBound ( t, mod_) => match t. trait_ {
2260
- Type :: ResolvedPath { path, param_names, .. } => SimpleBound :: TraitBound (
2261
- path. segments ,
2262
- param_names. map_or_else ( Vec :: new, |( v, _) | {
2263
- v. iter ( ) . map ( |p| SimpleBound :: from ( p. clone ( ) ) ) . collect ( )
2264
- } ) ,
2265
- t. generic_params ,
2266
- mod_,
2267
- ) ,
2233
+ Type :: ResolvedPath { path, .. } => {
2234
+ SimpleBound :: TraitBound ( path. segments , Vec :: new ( ) , t. generic_params , mod_)
2235
+ }
2268
2236
_ => panic ! ( "Unexpected bound {:?}" , bound) ,
2269
2237
} ,
2270
2238
}
0 commit comments