@@ -43,8 +43,7 @@ use rustc::metadata::cstore;
43
43
use rustc:: metadata:: csearch;
44
44
use rustc:: metadata:: decoder;
45
45
use rustc:: middle:: def;
46
- use rustc:: middle:: subst;
47
- use rustc:: middle:: subst:: VecPerParamSpace ;
46
+ use rustc:: middle:: subst:: { mod, ParamSpace , VecPerParamSpace } ;
48
47
use rustc:: middle:: ty;
49
48
use rustc:: middle:: stability;
50
49
use rustc:: session:: config;
@@ -493,7 +492,7 @@ impl<'tcx> Clean<TyParam> for ty::TypeParameterDef<'tcx> {
493
492
#[ deriving( Clone , RustcEncodable , RustcDecodable , PartialEq ) ]
494
493
pub enum TyParamBound {
495
494
RegionBound ( Lifetime ) ,
496
- TraitBound ( Type )
495
+ TraitBound ( PolyTrait )
497
496
}
498
497
499
498
impl Clean < TyParamBound > for ast:: TyParamBound {
@@ -558,10 +557,13 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
558
557
let fqn = fqn. into_iter ( ) . map ( |i| i. to_string ( ) ) . collect ( ) ;
559
558
cx. external_paths . borrow_mut ( ) . as_mut ( ) . unwrap ( ) . insert ( did,
560
559
( fqn, TypeTrait ) ) ;
561
- TraitBound ( ResolvedPath {
562
- path : path,
563
- typarams : None ,
564
- did : did,
560
+ TraitBound ( PolyTrait {
561
+ trait_ : ResolvedPath {
562
+ path : path,
563
+ typarams : None ,
564
+ did : did,
565
+ } ,
566
+ lifetimes : vec ! [ ]
565
567
} )
566
568
}
567
569
}
@@ -585,10 +587,31 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
585
587
& self . substs ) ;
586
588
cx. external_paths . borrow_mut ( ) . as_mut ( ) . unwrap ( ) . insert ( self . def_id ,
587
589
( fqn, TypeTrait ) ) ;
588
- TraitBound ( ResolvedPath {
589
- path : path,
590
- typarams : None ,
591
- did : self . def_id ,
590
+
591
+ debug ! ( "ty::TraitRef\n substs.types(TypeSpace): {}\n " ,
592
+ self . substs. types. get_slice( ParamSpace :: TypeSpace ) ) ;
593
+
594
+ // collect any late bound regions
595
+ let mut late_bounds = vec ! [ ] ;
596
+ for & ty_s in self . substs . types . get_slice ( ParamSpace :: TypeSpace ) . iter ( ) {
597
+ use rustc:: middle:: ty:: { Region , sty} ;
598
+ if let sty:: ty_tup( ref ts) = ty_s. sty {
599
+ for & ty_s in ts. iter ( ) {
600
+ if let sty:: ty_rptr( ref reg, _) = ty_s. sty {
601
+ if let & Region :: ReLateBound ( _, _) = reg {
602
+ debug ! ( " hit an ReLateBound {}" , reg) ;
603
+ if let Some ( lt) = reg. clean ( cx) {
604
+ late_bounds. push ( lt)
605
+ }
606
+ }
607
+ }
608
+ }
609
+ }
610
+ }
611
+
612
+ TraitBound ( PolyTrait {
613
+ trait_ : ResolvedPath { path : path, typarams : None , did : self . def_id , } ,
614
+ lifetimes : late_bounds
592
615
} )
593
616
}
594
617
}
@@ -615,7 +638,7 @@ impl<'tcx> Clean<(Vec<TyParamBound>, Option<Type>)> for ty::ParamBounds<'tcx> {
615
638
( v, None )
616
639
} else {
617
640
let ty = match ty:: BoundSized . clean ( cx) {
618
- TraitBound ( ty ) => ty ,
641
+ TraitBound ( polyt ) => polyt . trait_ ,
619
642
_ => unreachable ! ( )
620
643
} ;
621
644
( v, Some ( ty) )
@@ -627,7 +650,10 @@ impl<'tcx> Clean<Option<Vec<TyParamBound>>> for subst::Substs<'tcx> {
627
650
fn clean ( & self , cx : & DocContext ) -> Option < Vec < TyParamBound > > {
628
651
let mut v = Vec :: new ( ) ;
629
652
v. extend ( self . regions ( ) . iter ( ) . filter_map ( |r| r. clean ( cx) ) . map ( RegionBound ) ) ;
630
- v. extend ( self . types . iter ( ) . map ( |t| TraitBound ( t. clean ( cx) ) ) ) ;
653
+ v. extend ( self . types . iter ( ) . map ( |t| TraitBound ( PolyTrait {
654
+ trait_ : t. clean ( cx) ,
655
+ lifetimes : vec ! [ ]
656
+ } ) ) ) ;
631
657
if v. len ( ) > 0 { Some ( v) } else { None }
632
658
}
633
659
}
@@ -1006,9 +1032,12 @@ impl Clean<Type> for ast::TraitRef {
1006
1032
}
1007
1033
}
1008
1034
1009
- impl Clean < Type > for ast:: PolyTraitRef {
1010
- fn clean ( & self , cx : & DocContext ) -> Type {
1011
- self . trait_ref . clean ( cx)
1035
+ impl Clean < PolyTrait > for ast:: PolyTraitRef {
1036
+ fn clean ( & self , cx : & DocContext ) -> PolyTrait {
1037
+ PolyTrait {
1038
+ trait_ : self . trait_ref . clean ( cx) ,
1039
+ lifetimes : self . bound_lifetimes . clean ( cx)
1040
+ }
1012
1041
}
1013
1042
}
1014
1043
@@ -1129,6 +1158,13 @@ impl<'tcx> Clean<Item> for ty::ImplOrTraitItem<'tcx> {
1129
1158
}
1130
1159
}
1131
1160
1161
+ /// A trait reference, which may have higher ranked lifetimes.
1162
+ #[ deriving( Clone , RustcEncodable , RustcDecodable , PartialEq ) ]
1163
+ pub struct PolyTrait {
1164
+ pub trait_ : Type ,
1165
+ pub lifetimes : Vec < Lifetime >
1166
+ }
1167
+
1132
1168
/// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
1133
1169
/// type out of the AST/ty::ctxt given one of these, if more information is needed. Most importantly
1134
1170
/// it does not preserve mutability or boxes.
0 commit comments