14
14
pub use self :: Type :: * ;
15
15
pub use self :: PrimitiveType :: * ;
16
16
pub use self :: TypeKind :: * ;
17
- pub use self :: StructField :: * ;
18
17
pub use self :: VariantKind :: * ;
19
18
pub use self :: Mutability :: * ;
20
19
pub use self :: Import :: * ;
@@ -53,6 +52,7 @@ use std::env::current_dir;
53
52
use core:: DocContext ;
54
53
use doctree;
55
54
use visit_ast;
55
+ use html:: item_type:: ItemType ;
56
56
57
57
/// A stable identifier to the particular version of JSON output.
58
58
/// Increment this when the `Crate` and related structures change.
@@ -273,36 +273,49 @@ impl Item {
273
273
}
274
274
pub fn is_crate ( & self ) -> bool {
275
275
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 ,
278
279
}
279
280
}
280
281
pub fn is_mod ( & self ) -> bool {
281
- match self . inner { ModuleItem ( .. ) => true , _ => false }
282
+ ItemType :: from_item ( self ) == ItemType :: Module
282
283
}
283
284
pub fn is_trait ( & self ) -> bool {
284
- match self . inner { TraitItem ( .. ) => true , _ => false }
285
+ ItemType :: from_item ( self ) == ItemType :: Trait
285
286
}
286
287
pub fn is_struct ( & self ) -> bool {
287
- match self . inner { StructItem ( .. ) => true , _ => false }
288
+ ItemType :: from_item ( self ) == ItemType :: Struct
288
289
}
289
290
pub fn is_enum ( & self ) -> bool {
290
- match self . inner { EnumItem ( .. ) => true , _ => false }
291
+ ItemType :: from_item ( self ) == ItemType :: Module
291
292
}
292
293
pub fn is_fn ( & self ) -> bool {
293
- match self . inner { FunctionItem ( .. ) => true , _ => false }
294
+ ItemType :: from_item ( self ) == ItemType :: Function
294
295
}
295
296
pub fn is_associated_type ( & self ) -> bool {
296
- match self . inner { AssociatedTypeItem ( .. ) => true , _ => false }
297
+ ItemType :: from_item ( self ) == ItemType :: AssociatedType
297
298
}
298
299
pub fn is_associated_const ( & self ) -> bool {
299
- match self . inner { AssociatedConstItem ( .. ) => true , _ => false }
300
+ ItemType :: from_item ( self ) == ItemType :: AssociatedConst
300
301
}
301
302
pub fn is_method ( & self ) -> bool {
302
- match self . inner { MethodItem ( .. ) => true , _ => false }
303
+ ItemType :: from_item ( self ) == ItemType :: Method
303
304
}
304
305
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
+ }
306
319
}
307
320
308
321
pub fn stability_class ( & self ) -> String {
@@ -341,7 +354,7 @@ pub enum ItemEnum {
341
354
TyMethodItem ( TyMethod ) ,
342
355
/// A method with a body.
343
356
MethodItem ( Method ) ,
344
- StructFieldItem ( StructField ) ,
357
+ StructFieldItem ( Type ) ,
345
358
VariantItem ( Variant ) ,
346
359
/// `fn`s from an extern block
347
360
ForeignFunctionItem ( Function ) ,
@@ -352,6 +365,8 @@ pub enum ItemEnum {
352
365
AssociatedConstItem ( Type , Option < String > ) ,
353
366
AssociatedTypeItem ( Vec < TyParamBound > , Option < Type > ) ,
354
367
DefaultImplItem ( DefaultImpl ) ,
368
+ /// An item that has been stripped by a rustdoc pass
369
+ StrippedItem ( Box < ItemEnum > ) ,
355
370
}
356
371
357
372
#[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
@@ -1733,12 +1748,6 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
1733
1748
}
1734
1749
}
1735
1750
1736
- #[ derive( Clone , RustcEncodable , RustcDecodable , Debug ) ]
1737
- pub enum StructField {
1738
- HiddenStructField , // inserted later by strip passes
1739
- TypedStructField ( Type ) ,
1740
- }
1741
-
1742
1751
impl Clean < Item > for hir:: StructField {
1743
1752
fn clean ( & self , cx : & DocContext ) -> Item {
1744
1753
Item {
@@ -1749,7 +1758,7 @@ impl Clean<Item> for hir::StructField {
1749
1758
stability : get_stability ( cx, cx. map . local_def_id ( self . id ) ) ,
1750
1759
deprecation : get_deprecation ( cx, cx. map . local_def_id ( self . id ) ) ,
1751
1760
def_id : cx. map . local_def_id ( self . id ) ,
1752
- inner : StructFieldItem ( TypedStructField ( self . ty . clean ( cx) ) ) ,
1761
+ inner : StructFieldItem ( self . ty . clean ( cx) ) ,
1753
1762
}
1754
1763
}
1755
1764
}
@@ -1766,7 +1775,7 @@ impl<'tcx> Clean<Item> for ty::FieldDefData<'tcx, 'static> {
1766
1775
stability : get_stability ( cx, self . did ) ,
1767
1776
deprecation : get_deprecation ( cx, self . did ) ,
1768
1777
def_id : self . did ,
1769
- inner : StructFieldItem ( TypedStructField ( self . unsubst_ty ( ) . clean ( cx) ) ) ,
1778
+ inner : StructFieldItem ( self . unsubst_ty ( ) . clean ( cx) ) ,
1770
1779
}
1771
1780
}
1772
1781
}
@@ -1897,9 +1906,7 @@ impl<'tcx> Clean<Item> for ty::VariantDefData<'tcx, 'static> {
1897
1906
def_id : field. did ,
1898
1907
stability : get_stability ( cx, field. did ) ,
1899
1908
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) )
1903
1910
}
1904
1911
} ) . collect ( )
1905
1912
} )
0 commit comments