1212//! that clean them.
1313
1414pub use self :: Type :: * ;
15- pub use self :: TypeKind :: * ;
16- pub use self :: VariantKind :: * ;
1715pub use self :: Mutability :: * ;
18- pub use self :: Import :: * ;
1916pub use self :: ItemEnum :: * ;
2017pub use self :: Attribute :: * ;
2118pub use self :: TyParamBound :: * ;
@@ -319,7 +316,7 @@ impl Item {
319316 match self . inner {
320317 StructItem ( ref _struct) => Some ( _struct. fields_stripped ) ,
321318 UnionItem ( ref union) => Some ( union. fields_stripped ) ,
322- VariantItem ( Variant { kind : StructVariant ( ref vstruct) } ) => {
319+ VariantItem ( Variant { kind : VariantKind :: Struct ( ref vstruct) } ) => {
323320 Some ( vstruct. fields_stripped )
324321 } ,
325322 _ => None ,
@@ -688,7 +685,7 @@ impl Clean<TyParamBound> for ty::BuiltinBound {
688685 ( tcx. lang_items . sync_trait ( ) . unwrap ( ) ,
689686 external_path ( cx, "Sync" , None , false , vec ! [ ] , empty) ) ,
690687 } ;
691- inline:: record_extern_fqn ( cx, did, TypeTrait ) ;
688+ inline:: record_extern_fqn ( cx, did, TypeKind :: Trait ) ;
692689 TraitBound ( PolyTrait {
693690 trait_ : ResolvedPath {
694691 path : path,
@@ -707,7 +704,7 @@ impl<'tcx> Clean<TyParamBound> for ty::TraitRef<'tcx> {
707704 Some ( tcx) => tcx,
708705 None => return RegionBound ( Lifetime :: statik ( ) )
709706 } ;
710- inline:: record_extern_fqn ( cx, self . def_id , TypeTrait ) ;
707+ inline:: record_extern_fqn ( cx, self . def_id , TypeKind :: Trait ) ;
711708 let path = external_path ( cx, & tcx. item_name ( self . def_id ) . as_str ( ) ,
712709 Some ( self . def_id ) , true , vec ! [ ] , self . substs ) ;
713710
@@ -765,7 +762,7 @@ impl Lifetime {
765762 pub fn get_ref < ' a > ( & ' a self ) -> & ' a str {
766763 let Lifetime ( ref s) = * self ;
767764 let s: & ' a str = s;
768- return s ;
765+ s
769766 }
770767
771768 pub fn statik ( ) -> Lifetime {
@@ -1130,7 +1127,7 @@ pub struct FnDecl {
11301127
11311128impl FnDecl {
11321129 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"
11341131 }
11351132
11361133 pub fn self_type ( & self ) -> Option < SelfTy > {
@@ -1480,16 +1477,16 @@ pub enum PrimitiveType {
14801477
14811478#[ derive( Clone , RustcEncodable , RustcDecodable , Copy , Debug ) ]
14821479pub 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 ,
14931490}
14941491
14951492pub trait GetDefId {
@@ -1572,7 +1569,7 @@ impl PrimitiveType {
15721569 None
15731570 }
15741571
1575- pub fn to_string ( & self ) -> & ' static str {
1572+ pub fn as_str ( & self ) -> & ' static str {
15761573 match * self {
15771574 PrimitiveType :: Isize => "isize" ,
15781575 PrimitiveType :: I8 => "i8" ,
@@ -1597,7 +1594,7 @@ impl PrimitiveType {
15971594 }
15981595
15991596 pub fn to_url_str ( & self ) -> & ' static str {
1600- self . to_string ( )
1597+ self . as_str ( )
16011598 }
16021599
16031600 /// Creates a rustdoc-specific node id for primitive types.
@@ -1795,9 +1792,9 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
17951792 ty:: TyAdt ( def, substs) => {
17961793 let did = def. did ;
17971794 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 ,
18011798 } ;
18021799 inline:: record_extern_fqn ( cx, did, kind) ;
18031800 let path = external_path ( cx, & cx. tcx ( ) . item_name ( did) . as_str ( ) ,
@@ -1811,7 +1808,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
18111808 }
18121809 ty:: TyTrait ( ref obj) => {
18131810 let did = obj. principal . def_id ( ) ;
1814- inline:: record_extern_fqn ( cx, did, TypeTrait ) ;
1811+ inline:: record_extern_fqn ( cx, did, TypeKind :: Trait ) ;
18151812
18161813 let mut typarams = vec ! [ ] ;
18171814 obj. region_bound . clean ( cx) . map ( |b| typarams. push ( RegionBound ( b) ) ) ;
@@ -2027,7 +2024,7 @@ impl Clean<Item> for doctree::Variant {
20272024 deprecation : self . depr . clean ( cx) ,
20282025 def_id : cx. map . local_def_id ( self . def . id ( ) ) ,
20292026 inner : VariantItem ( Variant {
2030- kind : struct_def_to_variant_kind ( & self . def , cx) ,
2027+ kind : self . def . clean ( cx) ,
20312028 } ) ,
20322029 }
20332030 }
@@ -2036,14 +2033,14 @@ impl Clean<Item> for doctree::Variant {
20362033impl < ' tcx > Clean < Item > for ty:: VariantDefData < ' tcx , ' static > {
20372034 fn clean ( & self , cx : & DocContext ) -> Item {
20382035 let kind = match self . kind {
2039- ty:: VariantKind :: Unit => CLikeVariant ,
2036+ ty:: VariantKind :: Unit => VariantKind :: CLike ,
20402037 ty:: VariantKind :: Tuple => {
2041- TupleVariant (
2038+ VariantKind :: Tuple (
20422039 self . fields . iter ( ) . map ( |f| f. unsubst_ty ( ) . clean ( cx) ) . collect ( )
20432040 )
20442041 }
20452042 ty:: VariantKind :: Struct => {
2046- StructVariant ( VariantStruct {
2043+ VariantKind :: Struct ( VariantStruct {
20472044 struct_type : doctree:: Plain ,
20482045 fields_stripped : false ,
20492046 fields : self . fields . iter ( ) . map ( |field| {
@@ -2076,18 +2073,20 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
20762073
20772074#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
20782075pub enum VariantKind {
2079- CLikeVariant ,
2080- TupleVariant ( Vec < Type > ) ,
2081- StructVariant ( VariantStruct ) ,
2076+ CLike ,
2077+ Tuple ( Vec < Type > ) ,
2078+ Struct ( VariantStruct ) ,
20822079}
20832080
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+ }
20912090 }
20922091}
20932092
@@ -2526,7 +2525,7 @@ impl Clean<Vec<Item>> for doctree::Import {
25262525 } ) ;
25272526 let ( mut ret, inner) = match self . node {
25282527 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 ) ) )
25302529 }
25312530 hir:: ViewPathList ( ref p, ref list) => {
25322531 // Attempt to inline all reexported items, but be sure
@@ -2552,17 +2551,16 @@ impl Clean<Vec<Item>> for doctree::Import {
25522551 if remaining. is_empty ( ) {
25532552 return ret;
25542553 }
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) )
25572555 }
25582556 hir:: ViewPathSimple ( name, ref p) => {
25592557 if !denied {
25602558 if let Some ( items) = inline:: try_inline ( cx, self . id , Some ( name) ) {
25612559 return items;
25622560 }
25632561 }
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 ) ) )
25662564 }
25672565 } ;
25682566 ret. push ( Item {
@@ -2582,11 +2580,11 @@ impl Clean<Vec<Item>> for doctree::Import {
25822580#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
25832581pub enum Import {
25842582 // use source as str;
2585- SimpleImport ( String , ImportSource ) ,
2583+ Simple ( String , ImportSource ) ,
25862584 // use source::*;
2587- GlobImport ( ImportSource ) ,
2585+ Glob ( ImportSource ) ,
25882586 // use source::{a, b, c};
2589- ImportList ( ImportSource , Vec < ViewListIdent > ) ,
2587+ List ( ImportSource , Vec < ViewListIdent > ) ,
25902588}
25912589
25922590#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -2761,24 +2759,24 @@ fn register_def(cx: &DocContext, def: Def) -> DefId {
27612759 let tcx = cx. tcx ( ) ;
27622760
27632761 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 ) ,
27742772 Def :: SelfTy ( _, Some ( impl_def_id) ) => {
27752773 return impl_def_id
27762774 }
27772775 _ => return def. def_id ( )
27782776 } ;
27792777 if did. is_local ( ) { return did }
27802778 inline:: record_extern_fqn ( cx, did, kind) ;
2781- if let TypeTrait = kind {
2779+ if let TypeKind :: Trait = kind {
27822780 let t = inline:: build_external_trait ( cx, tcx, did) ;
27832781 cx. external_traits . borrow_mut ( ) . insert ( did, t) ;
27842782 }
@@ -2966,7 +2964,7 @@ fn lang_struct(cx: &DocContext, did: Option<DefId>,
29662964 Some ( did) => did,
29672965 None => return fallback ( box t. clean ( cx) ) ,
29682966 } ;
2969- inline:: record_extern_fqn ( cx, did, TypeStruct ) ;
2967+ inline:: record_extern_fqn ( cx, did, TypeKind :: Struct ) ;
29702968 ResolvedPath {
29712969 typarams : None ,
29722970 did : did,
0 commit comments