12
12
//! that clean them.
13
13
14
14
pub use self :: Type :: * ;
15
- pub use self :: TypeKind :: * ;
16
- pub use self :: VariantKind :: * ;
17
15
pub use self :: Mutability :: * ;
18
- pub use self :: Import :: * ;
19
16
pub use self :: ItemEnum :: * ;
20
17
pub use self :: Attribute :: * ;
21
18
pub use self :: TyParamBound :: * ;
@@ -319,7 +316,7 @@ impl Item {
319
316
match self . inner {
320
317
StructItem ( ref _struct) => Some ( _struct. fields_stripped ) ,
321
318
UnionItem ( ref union) => Some ( union. fields_stripped ) ,
322
- VariantItem ( Variant { kind : StructVariant ( ref vstruct) } ) => {
319
+ VariantItem ( Variant { kind : VariantKind :: Struct ( ref vstruct) } ) => {
323
320
Some ( vstruct. fields_stripped )
324
321
} ,
325
322
_ => None ,
@@ -688,7 +685,7 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
688
685
( tcx. lang_items . sync_trait ( ) . unwrap ( ) ,
689
686
external_path ( cx, "Sync" , None , false , vec ! [ ] , empty) ) ,
690
687
} ;
691
- inline:: record_extern_fqn ( cx, did, TypeTrait ) ;
688
+ inline:: record_extern_fqn ( cx, did, TypeKind :: Trait ) ;
692
689
TraitBound ( PolyTrait {
693
690
trait_ : ResolvedPath {
694
691
path : path,
@@ -707,7 +704,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
707
704
Some ( tcx) => tcx,
708
705
None => return RegionBound ( Lifetime :: statik ( ) )
709
706
} ;
710
- inline:: record_extern_fqn ( cx, self . def_id , TypeTrait ) ;
707
+ inline:: record_extern_fqn ( cx, self . def_id , TypeKind :: Trait ) ;
711
708
let path = external_path ( cx, & tcx. item_name ( self . def_id ) . as_str ( ) ,
712
709
Some ( self . def_id ) , true , vec ! [ ] , self . substs ) ;
713
710
@@ -765,7 +762,7 @@ impl Lifetime {
765
762
pub fn get_ref < ' a > ( & ' a self ) -> & ' a str {
766
763
let Lifetime ( ref s) = * self ;
767
764
let s: & ' a str = s;
768
- return s ;
765
+ s
769
766
}
770
767
771
768
pub fn statik ( ) -> Lifetime {
@@ -1130,7 +1127,7 @@ pub struct FnDecl {
1130
1127
1131
1128
impl FnDecl {
1132
1129
pub fn has_self ( & self ) -> bool {
1133
- return self . inputs . values . len ( ) > 0 && self . inputs . values [ 0 ] . name == "self" ;
1130
+ self . inputs . values . len ( ) > 0 && self . inputs . values [ 0 ] . name == "self"
1134
1131
}
1135
1132
1136
1133
pub fn self_type ( & self ) -> Option < SelfTy > {
@@ -1480,16 +1477,16 @@ pub enum PrimitiveType {
1480
1477
1481
1478
#[ derive( Clone , RustcEncodable , RustcDecodable , Copy , Debug ) ]
1482
1479
pub enum TypeKind {
1483
- TypeEnum ,
1484
- TypeFunction ,
1485
- TypeModule ,
1486
- TypeConst ,
1487
- TypeStatic ,
1488
- TypeStruct ,
1489
- TypeUnion ,
1490
- TypeTrait ,
1491
- TypeVariant ,
1492
- TypeTypedef ,
1480
+ Enum ,
1481
+ Function ,
1482
+ Module ,
1483
+ Const ,
1484
+ Static ,
1485
+ Struct ,
1486
+ Union ,
1487
+ Trait ,
1488
+ Variant ,
1489
+ Typedef ,
1493
1490
}
1494
1491
1495
1492
pub trait GetDefId {
@@ -1572,7 +1569,7 @@ impl PrimitiveType {
1572
1569
None
1573
1570
}
1574
1571
1575
- pub fn to_string ( & self ) -> & ' static str {
1572
+ pub fn as_str ( & self ) -> & ' static str {
1576
1573
match * self {
1577
1574
PrimitiveType :: Isize => "isize" ,
1578
1575
PrimitiveType :: I8 => "i8" ,
@@ -1597,7 +1594,7 @@ impl PrimitiveType {
1597
1594
}
1598
1595
1599
1596
pub fn to_url_str ( & self ) -> & ' static str {
1600
- self . to_string ( )
1597
+ self . as_str ( )
1601
1598
}
1602
1599
1603
1600
/// Creates a rustdoc-specific node id for primitive types.
@@ -1795,9 +1792,9 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
1795
1792
ty:: TyAdt ( def, substs) => {
1796
1793
let did = def. did ;
1797
1794
let kind = match def. adt_kind ( ) {
1798
- AdtKind :: Struct => TypeStruct ,
1799
- AdtKind :: Union => TypeUnion ,
1800
- AdtKind :: Enum => TypeEnum ,
1795
+ AdtKind :: Struct => TypeKind :: Struct ,
1796
+ AdtKind :: Union => TypeKind :: Union ,
1797
+ AdtKind :: Enum => TypeKind :: Enum ,
1801
1798
} ;
1802
1799
inline:: record_extern_fqn ( cx, did, kind) ;
1803
1800
let path = external_path ( cx, & cx. tcx ( ) . item_name ( did) . as_str ( ) ,
@@ -1811,7 +1808,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
1811
1808
}
1812
1809
ty:: TyTrait ( ref obj) => {
1813
1810
let did = obj. principal . def_id ( ) ;
1814
- inline:: record_extern_fqn ( cx, did, TypeTrait ) ;
1811
+ inline:: record_extern_fqn ( cx, did, TypeKind :: Trait ) ;
1815
1812
1816
1813
let mut typarams = vec ! [ ] ;
1817
1814
obj. region_bound . clean ( cx) . map ( |b| typarams. push ( RegionBound ( b) ) ) ;
@@ -2027,7 +2024,7 @@ impl Clean<Item> for doctree::Variant {
2027
2024
deprecation : self . depr . clean ( cx) ,
2028
2025
def_id : cx. map . local_def_id ( self . def . id ( ) ) ,
2029
2026
inner : VariantItem ( Variant {
2030
- kind : struct_def_to_variant_kind ( & self . def , cx) ,
2027
+ kind : self . def . clean ( cx) ,
2031
2028
} ) ,
2032
2029
}
2033
2030
}
@@ -2036,14 +2033,14 @@ impl Clean<Item> for doctree::Variant {
2036
2033
impl < ' tcx > Clean < Item > for ty:: VariantDefData < ' tcx , ' static > {
2037
2034
fn clean ( & self , cx : & DocContext ) -> Item {
2038
2035
let kind = match self . kind {
2039
- ty:: VariantKind :: Unit => CLikeVariant ,
2036
+ ty:: VariantKind :: Unit => VariantKind :: CLike ,
2040
2037
ty:: VariantKind :: Tuple => {
2041
- TupleVariant (
2038
+ VariantKind :: Tuple (
2042
2039
self . fields . iter ( ) . map ( |f| f. unsubst_ty ( ) . clean ( cx) ) . collect ( )
2043
2040
)
2044
2041
}
2045
2042
ty:: VariantKind :: Struct => {
2046
- StructVariant ( VariantStruct {
2043
+ VariantKind :: Struct ( VariantStruct {
2047
2044
struct_type : doctree:: Plain ,
2048
2045
fields_stripped : false ,
2049
2046
fields : self . fields . iter ( ) . map ( |field| {
@@ -2076,18 +2073,20 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
2076
2073
2077
2074
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
2078
2075
pub enum VariantKind {
2079
- CLikeVariant ,
2080
- TupleVariant ( Vec < Type > ) ,
2081
- StructVariant ( VariantStruct ) ,
2076
+ CLike ,
2077
+ Tuple ( Vec < Type > ) ,
2078
+ Struct ( VariantStruct ) ,
2082
2079
}
2083
2080
2084
- fn struct_def_to_variant_kind ( struct_def : & hir:: VariantData , cx : & DocContext ) -> VariantKind {
2085
- if struct_def. is_struct ( ) {
2086
- StructVariant ( struct_def. clean ( cx) )
2087
- } else if struct_def. is_unit ( ) {
2088
- CLikeVariant
2089
- } else {
2090
- TupleVariant ( struct_def. fields ( ) . iter ( ) . map ( |x| x. ty . clean ( cx) ) . collect ( ) )
2081
+ impl Clean < VariantKind > for hir:: VariantData {
2082
+ fn clean ( & self , cx : & DocContext ) -> VariantKind {
2083
+ if self . is_struct ( ) {
2084
+ VariantKind :: Struct ( self . clean ( cx) )
2085
+ } else if self . is_unit ( ) {
2086
+ VariantKind :: CLike
2087
+ } else {
2088
+ VariantKind :: Tuple ( self . fields ( ) . iter ( ) . map ( |x| x. ty . clean ( cx) ) . collect ( ) )
2089
+ }
2091
2090
}
2092
2091
}
2093
2092
@@ -2526,7 +2525,7 @@ impl Clean<Vec<Item>> for doctree::Import {
2526
2525
} ) ;
2527
2526
let ( mut ret, inner) = match self . node {
2528
2527
hir:: ViewPathGlob ( ref p) => {
2529
- ( vec ! [ ] , GlobImport ( resolve_use_source ( cx, p. clean ( cx) , self . id ) ) )
2528
+ ( vec ! [ ] , Import :: Glob ( resolve_use_source ( cx, p. clean ( cx) , self . id ) ) )
2530
2529
}
2531
2530
hir:: ViewPathList ( ref p, ref list) => {
2532
2531
// Attempt to inline all reexported items, but be sure
@@ -2552,17 +2551,16 @@ impl Clean<Vec<Item>> for doctree::Import {
2552
2551
if remaining. is_empty ( ) {
2553
2552
return ret;
2554
2553
}
2555
- ( ret, ImportList ( resolve_use_source ( cx, p. clean ( cx) , self . id ) ,
2556
- remaining) )
2554
+ ( ret, Import :: List ( resolve_use_source ( cx, p. clean ( cx) , self . id ) , remaining) )
2557
2555
}
2558
2556
hir:: ViewPathSimple ( name, ref p) => {
2559
2557
if !denied {
2560
2558
if let Some ( items) = inline:: try_inline ( cx, self . id , Some ( name) ) {
2561
2559
return items;
2562
2560
}
2563
2561
}
2564
- ( vec ! [ ] , SimpleImport ( name. clean ( cx) ,
2565
- resolve_use_source ( cx, p. clean ( cx) , self . id ) ) )
2562
+ ( vec ! [ ] , Import :: Simple ( name. clean ( cx) ,
2563
+ resolve_use_source ( cx, p. clean ( cx) , self . id ) ) )
2566
2564
}
2567
2565
} ;
2568
2566
ret. push ( Item {
@@ -2582,11 +2580,11 @@ impl Clean<Vec<Item>> for doctree::Import {
2582
2580
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
2583
2581
pub enum Import {
2584
2582
// use source as str;
2585
- SimpleImport ( String , ImportSource ) ,
2583
+ Simple ( String , ImportSource ) ,
2586
2584
// use source::*;
2587
- GlobImport ( ImportSource ) ,
2585
+ Glob ( ImportSource ) ,
2588
2586
// use source::{a, b, c};
2589
- ImportList ( ImportSource , Vec < ViewListIdent > ) ,
2587
+ List ( ImportSource , Vec < ViewListIdent > ) ,
2590
2588
}
2591
2589
2592
2590
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -2761,24 +2759,24 @@ fn register_def(cx: &DocContext, def: Def) -> DefId {
2761
2759
let tcx = cx. tcx ( ) ;
2762
2760
2763
2761
let ( did, kind) = match def {
2764
- Def :: Fn ( i) => ( i, TypeFunction ) ,
2765
- Def :: TyAlias ( i) => ( i, TypeTypedef ) ,
2766
- Def :: Enum ( i) => ( i, TypeEnum ) ,
2767
- Def :: Trait ( i) => ( i, TypeTrait ) ,
2768
- Def :: Struct ( i) => ( i, TypeStruct ) ,
2769
- Def :: Union ( i) => ( i, TypeUnion ) ,
2770
- Def :: Mod ( i) => ( i, TypeModule ) ,
2771
- Def :: Static ( i, _) => ( i, TypeStatic ) ,
2772
- Def :: Variant ( i) => ( tcx. parent_def_id ( i) . unwrap ( ) , TypeEnum ) ,
2773
- Def :: SelfTy ( Some ( def_id) , _) => ( def_id, TypeTrait ) ,
2762
+ Def :: Fn ( i) => ( i, TypeKind :: Function ) ,
2763
+ Def :: TyAlias ( i) => ( i, TypeKind :: Typedef ) ,
2764
+ Def :: Enum ( i) => ( i, TypeKind :: Enum ) ,
2765
+ Def :: Trait ( i) => ( i, TypeKind :: Trait ) ,
2766
+ Def :: Struct ( i) => ( i, TypeKind :: Struct ) ,
2767
+ Def :: Union ( i) => ( i, TypeKind :: Union ) ,
2768
+ Def :: Mod ( i) => ( i, TypeKind :: Module ) ,
2769
+ Def :: Static ( i, _) => ( i, TypeKind :: Static ) ,
2770
+ Def :: Variant ( i) => ( tcx. parent_def_id ( i) . unwrap ( ) , TypeKind :: Enum ) ,
2771
+ Def :: SelfTy ( Some ( def_id) , _) => ( def_id, TypeKind :: Trait ) ,
2774
2772
Def :: SelfTy ( _, Some ( impl_def_id) ) => {
2775
2773
return impl_def_id
2776
2774
}
2777
2775
_ => return def. def_id ( )
2778
2776
} ;
2779
2777
if did. is_local ( ) { return did }
2780
2778
inline:: record_extern_fqn ( cx, did, kind) ;
2781
- if let TypeTrait = kind {
2779
+ if let TypeKind :: Trait = kind {
2782
2780
let t = inline:: build_external_trait ( cx, tcx, did) ;
2783
2781
cx. external_traits . borrow_mut ( ) . insert ( did, t) ;
2784
2782
}
@@ -2966,7 +2964,7 @@ fn lang_struct(cx: &DocContext, did: Option<DefId>,
2966
2964
Some ( did) => did,
2967
2965
None => return fallback ( box t. clean ( cx) ) ,
2968
2966
} ;
2969
- inline:: record_extern_fqn ( cx, did, TypeStruct ) ;
2967
+ inline:: record_extern_fqn ( cx, did, TypeKind :: Struct ) ;
2970
2968
ResolvedPath {
2971
2969
typarams : None ,
2972
2970
did : did,
0 commit comments