@@ -343,7 +343,7 @@ pub enum ItemEnum {
343343 EnumItem ( Enum ) ,
344344 FunctionItem ( Function ) ,
345345 ModuleItem ( Module ) ,
346- TypedefItem ( Typedef ) ,
346+ TypedefItem ( Typedef , bool /* is associated type */ ) ,
347347 StaticItem ( Static ) ,
348348 ConstantItem ( Constant ) ,
349349 TraitItem ( Trait ) ,
@@ -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 }
@@ -1286,7 +1292,7 @@ impl Clean<Item> for ast::ImplItem {
12861292 type_params : Vec :: new ( ) ,
12871293 where_predicates : Vec :: new ( )
12881294 } ,
1289- } ) ,
1295+ } , true ) ,
12901296 ast:: MacImplItem ( _) => {
12911297 MacroItem ( Macro {
12921298 source : self . span . to_src ( cx) ,
@@ -1401,11 +1407,13 @@ pub struct PolyTrait {
14011407/// it does not preserve mutability or boxes.
14021408#[ derive( Clone , RustcEncodable , RustcDecodable , PartialEq , Debug ) ]
14031409pub enum Type {
1404- /// structs/enums/traits (anything that'd be an ast::TyPath)
1410+ /// structs/enums/traits (most that'd be an ast::TyPath)
14051411 ResolvedPath {
14061412 path : Path ,
14071413 typarams : Option < Vec < TyParamBound > > ,
14081414 did : ast:: DefId ,
1415+ /// true if is a `T::Name` path for associated types
1416+ is_generic : bool ,
14091417 } ,
14101418 /// For parameterized types, so the consumer of the JSON don't go
14111419 /// looking for types which don't exist anywhere.
@@ -1594,8 +1602,13 @@ impl Clean<Type> for ast::Ty {
15941602 TyObjectSum ( ref lhs, ref bounds) => {
15951603 let lhs_ty = lhs. clean ( cx) ;
15961604 match lhs_ty {
1597- ResolvedPath { path, typarams : None , did } => {
1598- ResolvedPath { path : path, typarams : Some ( bounds. clean ( cx) ) , did : did}
1605+ ResolvedPath { path, typarams : None , did, is_generic } => {
1606+ ResolvedPath {
1607+ path : path,
1608+ typarams : Some ( bounds. clean ( cx) ) ,
1609+ did : did,
1610+ is_generic : is_generic,
1611+ }
15991612 }
16001613 _ => {
16011614 lhs_ty // shouldn't happen
@@ -1675,6 +1688,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
16751688 path : path,
16761689 typarams : None ,
16771690 did : did,
1691+ is_generic : false ,
16781692 }
16791693 }
16801694 ty:: ty_trait( box ty:: TyTrait { ref principal, ref bounds } ) => {
@@ -1689,6 +1703,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
16891703 path : path,
16901704 typarams : Some ( typarams) ,
16911705 did : did,
1706+ is_generic : false ,
16921707 }
16931708 }
16941709 ty:: ty_tup( ref t) => Tuple ( t. clean ( cx) ) ,
@@ -2085,7 +2100,7 @@ impl Clean<Item> for doctree::Typedef {
20852100 inner : TypedefItem ( Typedef {
20862101 type_ : self . ty . clean ( cx) ,
20872102 generics : self . gen . clean ( cx) ,
2088- } ) ,
2103+ } , false ) ,
20892104 }
20902105 }
20912106}
@@ -2255,7 +2270,7 @@ fn build_deref_target_impls(cx: &DocContext,
22552270
22562271 for item in items {
22572272 let target = match item. inner {
2258- TypedefItem ( ref t) => & t. type_ ,
2273+ TypedefItem ( ref t, true ) => & t. type_ ,
22592274 _ => continue ,
22602275 } ;
22612276 let primitive = match * target {
@@ -2580,10 +2595,7 @@ fn resolve_type(cx: &DocContext,
25802595 None => panic ! ( "unresolved id not in defmap" )
25812596 } ;
25822597
2583- match def {
2584- def:: DefSelfTy ( ..) if path. segments . len ( ) == 1 => {
2585- return Generic ( token:: get_name ( special_idents:: type_self. name ) . to_string ( ) ) ;
2586- }
2598+ let is_generic = match def {
25872599 def:: DefPrimTy ( p) => match p {
25882600 ast:: TyStr => return Primitive ( Str ) ,
25892601 ast:: TyBool => return Primitive ( Bool ) ,
@@ -2601,13 +2613,14 @@ fn resolve_type(cx: &DocContext,
26012613 ast:: TyFloat ( ast:: TyF32 ) => return Primitive ( F32 ) ,
26022614 ast:: TyFloat ( ast:: TyF64 ) => return Primitive ( F64 ) ,
26032615 } ,
2604- def:: DefTyParam ( _ , _ , _ , n ) => {
2605- return Generic ( token:: get_name ( n ) . to_string ( ) )
2616+ def:: DefSelfTy ( .. ) if path . segments . len ( ) == 1 => {
2617+ return Generic ( token:: get_name ( special_idents :: type_self . name ) . to_string ( ) ) ;
26062618 }
2607- _ => { }
2619+ def:: DefSelfTy ( ..) | def:: DefTyParam ( ..) => true ,
2620+ _ => false ,
26082621 } ;
26092622 let did = register_def ( & * cx, def) ;
2610- ResolvedPath { path : path, typarams : None , did : did }
2623+ ResolvedPath { path : path, typarams : None , did : did, is_generic : is_generic }
26112624}
26122625
26132626fn register_def ( cx : & DocContext , def : def:: Def ) -> ast:: DefId {
@@ -2821,6 +2834,7 @@ fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
28212834 }
28222835 } ] ,
28232836 } ,
2837+ is_generic : false ,
28242838 }
28252839}
28262840
0 commit comments