1414pub use self :: Type :: * ;
1515pub use self :: PrimitiveType :: * ;
1616pub use self :: TypeKind :: * ;
17- pub use self :: StructField :: * ;
1817pub use self :: VariantKind :: * ;
1918pub use self :: Mutability :: * ;
2019pub use self :: Import :: * ;
@@ -53,6 +52,7 @@ use std::env::current_dir;
5352use core:: DocContext ;
5453use doctree;
5554use visit_ast;
55+ use html:: item_type:: ItemType ;
5656
5757/// A stable identifier to the particular version of JSON output.
5858/// Increment this when the `Crate` and related structures change.
@@ -273,36 +273,49 @@ impl Item {
273273 }
274274 pub fn is_crate ( & self ) -> bool {
275275 match self . inner {
276- ModuleItem ( Module { items : _, is_crate : true } ) => true ,
277- _ => false
276+ StrippedItem ( box ModuleItem ( Module { is_crate : true , ..} ) ) |
277+ ModuleItem ( Module { is_crate : true , ..} ) => true ,
278+ _ => false ,
278279 }
279280 }
280281 pub fn is_mod ( & self ) -> bool {
281- match self . inner { ModuleItem ( .. ) => true , _ => false }
282+ ItemType :: from_item ( self ) == ItemType :: Module
282283 }
283284 pub fn is_trait ( & self ) -> bool {
284- match self . inner { TraitItem ( .. ) => true , _ => false }
285+ ItemType :: from_item ( self ) == ItemType :: Trait
285286 }
286287 pub fn is_struct ( & self ) -> bool {
287- match self . inner { StructItem ( .. ) => true , _ => false }
288+ ItemType :: from_item ( self ) == ItemType :: Struct
288289 }
289290 pub fn is_enum ( & self ) -> bool {
290- match self . inner { EnumItem ( .. ) => true , _ => false }
291+ ItemType :: from_item ( self ) == ItemType :: Module
291292 }
292293 pub fn is_fn ( & self ) -> bool {
293- match self . inner { FunctionItem ( .. ) => true , _ => false }
294+ ItemType :: from_item ( self ) == ItemType :: Function
294295 }
295296 pub fn is_associated_type ( & self ) -> bool {
296- match self . inner { AssociatedTypeItem ( .. ) => true , _ => false }
297+ ItemType :: from_item ( self ) == ItemType :: AssociatedType
297298 }
298299 pub fn is_associated_const ( & self ) -> bool {
299- match self . inner { AssociatedConstItem ( .. ) => true , _ => false }
300+ ItemType :: from_item ( self ) == ItemType :: AssociatedConst
300301 }
301302 pub fn is_method ( & self ) -> bool {
302- match self . inner { MethodItem ( .. ) => true , _ => false }
303+ ItemType :: from_item ( self ) == ItemType :: Method
303304 }
304305 pub fn is_ty_method ( & self ) -> bool {
305- match self . inner { TyMethodItem ( ..) => true , _ => false }
306+ ItemType :: from_item ( self ) == ItemType :: TyMethod
307+ }
308+ pub fn is_stripped ( & self ) -> bool {
309+ match self . inner { StrippedItem ( ..) => true , _ => false }
310+ }
311+ pub fn has_stripped_fields ( & self ) -> Option < bool > {
312+ match self . inner {
313+ StructItem ( ref _struct) => Some ( _struct. fields_stripped ) ,
314+ VariantItem ( Variant { kind : StructVariant ( ref vstruct) } ) => {
315+ Some ( vstruct. fields_stripped )
316+ } ,
317+ _ => None ,
318+ }
306319 }
307320
308321 pub fn stability_class ( & self ) -> String {
@@ -341,7 +354,7 @@ pub enum ItemEnum {
341354 TyMethodItem ( TyMethod ) ,
342355 /// A method with a body.
343356 MethodItem ( Method ) ,
344- StructFieldItem ( StructField ) ,
357+ StructFieldItem ( Type ) ,
345358 VariantItem ( Variant ) ,
346359 /// `fn`s from an extern block
347360 ForeignFunctionItem ( Function ) ,
@@ -352,6 +365,8 @@ pub enum ItemEnum {
352365 AssociatedConstItem ( Type , Option < String > ) ,
353366 AssociatedTypeItem ( Vec < TyParamBound > , Option < Type > ) ,
354367 DefaultImplItem ( DefaultImpl ) ,
368+ /// An item that has been stripped by a rustdoc pass
369+ StrippedItem ( Box < ItemEnum > ) ,
355370}
356371
357372#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -1733,12 +1748,6 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
17331748 }
17341749}
17351750
1736- #[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1737- pub enum StructField {
1738- HiddenStructField , // inserted later by strip passes
1739- TypedStructField ( Type ) ,
1740- }
1741-
17421751impl Clean < Item > for hir:: StructField {
17431752 fn clean ( & self , cx : & DocContext ) -> Item {
17441753 Item {
@@ -1749,7 +1758,7 @@ impl Clean<Item> for hir::StructField {
17491758 stability : get_stability ( cx, cx. map . local_def_id ( self . id ) ) ,
17501759 deprecation : get_deprecation ( cx, cx. map . local_def_id ( self . id ) ) ,
17511760 def_id : cx. map . local_def_id ( self . id ) ,
1752- inner : StructFieldItem ( TypedStructField ( self . ty . clean ( cx) ) ) ,
1761+ inner : StructFieldItem ( self . ty . clean ( cx) ) ,
17531762 }
17541763 }
17551764}
@@ -1766,7 +1775,7 @@ impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
17661775 stability : get_stability ( cx, self . did ) ,
17671776 deprecation : get_deprecation ( cx, self . did ) ,
17681777 def_id : self . did ,
1769- inner : StructFieldItem ( TypedStructField ( self . unsubst_ty ( ) . clean ( cx) ) ) ,
1778+ inner : StructFieldItem ( self . unsubst_ty ( ) . clean ( cx) ) ,
17701779 }
17711780 }
17721781}
@@ -1897,9 +1906,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
18971906 def_id : field. did ,
18981907 stability : get_stability ( cx, field. did ) ,
18991908 deprecation : get_deprecation ( cx, field. did ) ,
1900- inner : StructFieldItem (
1901- TypedStructField ( field. unsubst_ty ( ) . clean ( cx) )
1902- )
1909+ inner : StructFieldItem ( field. unsubst_ty ( ) . clean ( cx) )
19031910 }
19041911 } ) . collect ( )
19051912 } )
0 commit comments