@@ -1380,17 +1380,18 @@ fn external_path(cx: &DocContext, name: &str, trait_did: Option<DefId>, has_self
1380
1380
}
1381
1381
}
1382
1382
1383
- impl < ' tcx > Clean < TyParamBound > for ty:: TraitRef < ' tcx > {
1383
+ impl < ' a , ' tcx > Clean < TyParamBound > for ( & ' a ty:: TraitRef < ' tcx > , Vec < TypeBinding > ) {
1384
1384
fn clean ( & self , cx : & DocContext ) -> TyParamBound {
1385
- inline:: record_extern_fqn ( cx, self . def_id , TypeKind :: Trait ) ;
1386
- let path = external_path ( cx, & cx. tcx . item_name ( self . def_id ) ,
1387
- Some ( self . def_id ) , true , vec ! [ ] , self . substs ) ;
1385
+ let ( trait_ref, ref bounds) = * self ;
1386
+ inline:: record_extern_fqn ( cx, trait_ref. def_id , TypeKind :: Trait ) ;
1387
+ let path = external_path ( cx, & cx. tcx . item_name ( trait_ref. def_id ) ,
1388
+ Some ( trait_ref. def_id ) , true , bounds. clone ( ) , trait_ref. substs ) ;
1388
1389
1389
- debug ! ( "ty::TraitRef\n subst: {:?}\n " , self . substs) ;
1390
+ debug ! ( "ty::TraitRef\n subst: {:?}\n " , trait_ref . substs) ;
1390
1391
1391
1392
// collect any late bound regions
1392
1393
let mut late_bounds = vec ! [ ] ;
1393
- for ty_s in self . input_types ( ) . skip ( 1 ) {
1394
+ for ty_s in trait_ref . input_types ( ) . skip ( 1 ) {
1394
1395
if let ty:: TyTuple ( ts) = ty_s. sty {
1395
1396
for & ty_s in ts {
1396
1397
if let ty:: TyRef ( ref reg, _) = ty_s. sty {
@@ -1410,7 +1411,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
1410
1411
trait_ : ResolvedPath {
1411
1412
path,
1412
1413
typarams : None ,
1413
- did : self . def_id ,
1414
+ did : trait_ref . def_id ,
1414
1415
is_generic : false ,
1415
1416
} ,
1416
1417
generic_params : late_bounds,
@@ -1420,6 +1421,12 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
1420
1421
}
1421
1422
}
1422
1423
1424
+ impl < ' tcx > Clean < TyParamBound > for ty:: TraitRef < ' tcx > {
1425
+ fn clean ( & self , cx : & DocContext ) -> TyParamBound {
1426
+ ( self , vec ! [ ] ) . clean ( cx)
1427
+ }
1428
+ }
1429
+
1423
1430
impl < ' tcx > Clean < Option < Vec < TyParamBound > > > for Substs < ' tcx > {
1424
1431
fn clean ( & self , cx : & DocContext ) -> Option < Vec < TyParamBound > > {
1425
1432
let mut v = Vec :: new ( ) ;
@@ -2780,9 +2787,51 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
2780
2787
let predicates_of = cx. tcx . predicates_of ( def_id) ;
2781
2788
let substs = cx. tcx . lift ( & substs) . unwrap ( ) ;
2782
2789
let bounds = predicates_of. instantiate ( cx. tcx , substs) ;
2783
- ImplTrait ( bounds. predicates . into_iter ( ) . filter_map ( |predicate| {
2784
- predicate. to_opt_poly_trait_ref ( ) . clean ( cx)
2785
- } ) . collect ( ) )
2790
+ let mut regions = vec ! [ ] ;
2791
+ let mut has_sized = false ;
2792
+ let mut bounds = bounds. predicates . iter ( ) . filter_map ( |predicate| {
2793
+ let trait_ref = if let Some ( tr) = predicate. to_opt_poly_trait_ref ( ) {
2794
+ tr
2795
+ } else if let ty:: Predicate :: TypeOutlives ( pred) = * predicate {
2796
+ // these should turn up at the end
2797
+ pred. skip_binder ( ) . 1 . clean ( cx) . map ( |r| regions. push ( RegionBound ( r) ) ) ;
2798
+ return None ;
2799
+ } else {
2800
+ return None ;
2801
+ } ;
2802
+
2803
+ if let Some ( sized) = cx. tcx . lang_items ( ) . sized_trait ( ) {
2804
+ if trait_ref. def_id ( ) == sized {
2805
+ has_sized = true ;
2806
+ return None ;
2807
+ }
2808
+ }
2809
+
2810
+
2811
+ let bounds = bounds. predicates . iter ( ) . filter_map ( |pred|
2812
+ if let ty:: Predicate :: Projection ( proj) = * pred {
2813
+ let proj = proj. skip_binder ( ) ;
2814
+ if proj. projection_ty . trait_ref ( cx. tcx ) == * trait_ref. skip_binder ( ) {
2815
+ Some ( TypeBinding {
2816
+ name : cx. tcx . associated_item ( proj. projection_ty . item_def_id )
2817
+ . name . clean ( cx) ,
2818
+ ty : proj. ty . clean ( cx) ,
2819
+ } )
2820
+ } else {
2821
+ None
2822
+ }
2823
+ } else {
2824
+ None
2825
+ }
2826
+ ) . collect ( ) ;
2827
+
2828
+ Some ( ( trait_ref. skip_binder ( ) , bounds) . clean ( cx) )
2829
+ } ) . collect :: < Vec < _ > > ( ) ;
2830
+ bounds. extend ( regions) ;
2831
+ if !has_sized && !bounds. is_empty ( ) {
2832
+ bounds. insert ( 0 , TyParamBound :: maybe_sized ( cx) ) ;
2833
+ }
2834
+ ImplTrait ( bounds)
2786
2835
}
2787
2836
2788
2837
ty:: TyClosure ( ..) | ty:: TyGenerator ( ..) => Tuple ( vec ! [ ] ) , // FIXME(pcwalton)
0 commit comments