@@ -32,7 +32,7 @@ use syntax::attr;
3232use syntax:: attr:: { AttributeMethods , AttrMetaMethods } ;
3333use syntax:: codemap;
3434use syntax:: codemap:: { DUMMY_SP , Pos , Spanned } ;
35- use syntax:: parse:: token:: { self , InternedString , special_idents } ;
35+ use syntax:: parse:: token:: { self , InternedString } ;
3636use syntax:: ptr:: P ;
3737
3838use rustc_trans:: back:: link;
@@ -664,6 +664,7 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
664664 path : path,
665665 typarams : None ,
666666 did : did,
667+ is_generic : false ,
667668 } ,
668669 lifetimes : vec ! [ ]
669670 } , ast:: TraitBoundModifier :: None )
@@ -706,7 +707,12 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
706707 }
707708
708709 TraitBound ( PolyTrait {
709- trait_ : ResolvedPath { path : path, typarams : None , did : self . def_id , } ,
710+ trait_ : ResolvedPath {
711+ path : path,
712+ typarams : None ,
713+ did : self . def_id ,
714+ is_generic : false ,
715+ } ,
710716 lifetimes : late_bounds
711717 } , ast:: TraitBoundModifier :: None )
712718 }
@@ -1394,11 +1400,13 @@ pub struct PolyTrait {
13941400/// it does not preserve mutability or boxes.
13951401#[ derive( Clone , RustcEncodable , RustcDecodable , PartialEq , Debug ) ]
13961402pub enum Type {
1397- /// structs/enums/traits (anything that'd be an ast::TyPath)
1403+ /// structs/enums/traits (most that'd be an ast::TyPath)
13981404 ResolvedPath {
13991405 path : Path ,
14001406 typarams : Option < Vec < TyParamBound > > ,
14011407 did : ast:: DefId ,
1408+ /// true if is a `T::Name` path for associated types
1409+ is_generic : bool ,
14021410 } ,
14031411 /// For parameterized types, so the consumer of the JSON don't go
14041412 /// looking for types which don't exist anywhere.
@@ -1587,8 +1595,13 @@ impl Clean<Type> for ast::Ty {
15871595 TyObjectSum ( ref lhs, ref bounds) => {
15881596 let lhs_ty = lhs. clean ( cx) ;
15891597 match lhs_ty {
1590- ResolvedPath { path, typarams : None , did } => {
1591- ResolvedPath { path : path, typarams : Some ( bounds. clean ( cx) ) , did : did}
1598+ ResolvedPath { path, typarams : None , did, is_generic } => {
1599+ ResolvedPath {
1600+ path : path,
1601+ typarams : Some ( bounds. clean ( cx) ) ,
1602+ did : did,
1603+ is_generic : is_generic,
1604+ }
15921605 }
15931606 _ => {
15941607 lhs_ty // shouldn't happen
@@ -1668,6 +1681,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
16681681 path : path,
16691682 typarams : None ,
16701683 did : did,
1684+ is_generic : false ,
16711685 }
16721686 }
16731687 ty:: ty_trait( box ty:: TyTrait { ref principal, ref bounds } ) => {
@@ -1682,6 +1696,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
16821696 path : path,
16831697 typarams : Some ( typarams) ,
16841698 did : did,
1699+ is_generic : false ,
16851700 }
16861701 }
16871702 ty:: ty_tup( ref t) => Tuple ( t. clean ( cx) ) ,
@@ -2572,10 +2587,7 @@ fn resolve_type(cx: &DocContext,
25722587 None => panic ! ( "unresolved id not in defmap" )
25732588 } ;
25742589
2575- match def {
2576- def:: DefSelfTy ( ..) if path. segments . len ( ) == 1 => {
2577- return Generic ( token:: get_name ( special_idents:: type_self. name ) . to_string ( ) ) ;
2578- }
2590+ let is_generic = match def {
25792591 def:: DefPrimTy ( p) => match p {
25802592 ast:: TyStr => return Primitive ( Str ) ,
25812593 ast:: TyBool => return Primitive ( Bool ) ,
@@ -2593,13 +2605,11 @@ fn resolve_type(cx: &DocContext,
25932605 ast:: TyFloat ( ast:: TyF32 ) => return Primitive ( F32 ) ,
25942606 ast:: TyFloat ( ast:: TyF64 ) => return Primitive ( F64 ) ,
25952607 } ,
2596- def:: DefTyParam ( _, _, _, n) => {
2597- return Generic ( token:: get_name ( n) . to_string ( ) )
2598- }
2599- _ => { }
2608+ def:: DefTyParam ( ..) | def:: DefSelfTy ( ..) => true ,
2609+ _ => false ,
26002610 } ;
26012611 let did = register_def ( & * cx, def) ;
2602- ResolvedPath { path : path, typarams : None , did : did }
2612+ ResolvedPath { path : path, typarams : None , did : did, is_generic : is_generic }
26032613}
26042614
26052615fn register_def ( cx : & DocContext , def : def:: Def ) -> ast:: DefId {
@@ -2798,6 +2808,7 @@ fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
27982808 }
27992809 } ] ,
28002810 } ,
2811+ is_generic : false ,
28012812 }
28022813}
28032814
0 commit comments