@@ -32,7 +32,7 @@ use syntax::attr;
32
32
use syntax:: attr:: { AttributeMethods , AttrMetaMethods } ;
33
33
use syntax:: codemap;
34
34
use syntax:: codemap:: { DUMMY_SP , Pos , Spanned } ;
35
- use syntax:: parse:: token:: { self , InternedString , special_idents } ;
35
+ use syntax:: parse:: token:: { self , InternedString } ;
36
36
use syntax:: ptr:: P ;
37
37
38
38
use rustc_trans:: back:: link;
@@ -664,6 +664,7 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
664
664
path : path,
665
665
typarams : None ,
666
666
did : did,
667
+ is_generic : false ,
667
668
} ,
668
669
lifetimes : vec ! [ ]
669
670
} , ast:: TraitBoundModifier :: None )
@@ -706,7 +707,12 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
706
707
}
707
708
708
709
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
+ } ,
710
716
lifetimes : late_bounds
711
717
} , ast:: TraitBoundModifier :: None )
712
718
}
@@ -1394,11 +1400,13 @@ pub struct PolyTrait {
1394
1400
/// it does not preserve mutability or boxes.
1395
1401
#[ derive( Clone , RustcEncodable , RustcDecodable , PartialEq , Debug ) ]
1396
1402
pub enum Type {
1397
- /// structs/enums/traits (anything that'd be an ast::TyPath)
1403
+ /// structs/enums/traits (most that'd be an ast::TyPath)
1398
1404
ResolvedPath {
1399
1405
path : Path ,
1400
1406
typarams : Option < Vec < TyParamBound > > ,
1401
1407
did : ast:: DefId ,
1408
+ /// true if is a `T::Name` path for associated types
1409
+ is_generic : bool ,
1402
1410
} ,
1403
1411
/// For parameterized types, so the consumer of the JSON don't go
1404
1412
/// looking for types which don't exist anywhere.
@@ -1587,8 +1595,13 @@ impl Clean<Type> for ast::Ty {
1587
1595
TyObjectSum ( ref lhs, ref bounds) => {
1588
1596
let lhs_ty = lhs. clean ( cx) ;
1589
1597
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
+ }
1592
1605
}
1593
1606
_ => {
1594
1607
lhs_ty // shouldn't happen
@@ -1668,6 +1681,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
1668
1681
path : path,
1669
1682
typarams : None ,
1670
1683
did : did,
1684
+ is_generic : false ,
1671
1685
}
1672
1686
}
1673
1687
ty:: ty_trait( box ty:: TyTrait { ref principal, ref bounds } ) => {
@@ -1682,6 +1696,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
1682
1696
path : path,
1683
1697
typarams : Some ( typarams) ,
1684
1698
did : did,
1699
+ is_generic : false ,
1685
1700
}
1686
1701
}
1687
1702
ty:: ty_tup( ref t) => Tuple ( t. clean ( cx) ) ,
@@ -2572,10 +2587,7 @@ fn resolve_type(cx: &DocContext,
2572
2587
None => panic ! ( "unresolved id not in defmap" )
2573
2588
} ;
2574
2589
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 {
2579
2591
def:: DefPrimTy ( p) => match p {
2580
2592
ast:: TyStr => return Primitive ( Str ) ,
2581
2593
ast:: TyBool => return Primitive ( Bool ) ,
@@ -2593,13 +2605,11 @@ fn resolve_type(cx: &DocContext,
2593
2605
ast:: TyFloat ( ast:: TyF32 ) => return Primitive ( F32 ) ,
2594
2606
ast:: TyFloat ( ast:: TyF64 ) => return Primitive ( F64 ) ,
2595
2607
} ,
2596
- def:: DefTyParam ( _, _, _, n) => {
2597
- return Generic ( token:: get_name ( n) . to_string ( ) )
2598
- }
2599
- _ => { }
2608
+ def:: DefTyParam ( ..) | def:: DefSelfTy ( ..) => true ,
2609
+ _ => false ,
2600
2610
} ;
2601
2611
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 }
2603
2613
}
2604
2614
2605
2615
fn register_def ( cx : & DocContext , def : def:: Def ) -> ast:: DefId {
@@ -2798,6 +2808,7 @@ fn lang_struct(cx: &DocContext, did: Option<ast::DefId>,
2798
2808
}
2799
2809
} ] ,
2800
2810
} ,
2811
+ is_generic : false ,
2801
2812
}
2802
2813
}
2803
2814
0 commit comments