@@ -1204,6 +1204,49 @@ impl Clean<Item> for doctree::Variant {
1204
1204
}
1205
1205
}
1206
1206
1207
+ impl Clean < Item > for ty:: VariantInfo {
1208
+ fn clean ( & self ) -> Item {
1209
+ // use syntax::parse::token::special_idents::unnamed_field;
1210
+ let cx = super :: ctxtkey. get ( ) . unwrap ( ) ;
1211
+ let tcx = match cx. maybe_typed {
1212
+ core:: Typed ( ref tycx) => tycx,
1213
+ core:: NotTyped ( _) => fail ! ( "tcx not present" ) ,
1214
+ } ;
1215
+ let kind = match self . arg_names . as_ref ( ) . map ( |s| s. as_slice ( ) ) {
1216
+ None | Some ( [ ] ) if self . args . len ( ) == 0 => CLikeVariant ,
1217
+ None | Some ( [ ] ) => {
1218
+ TupleVariant ( self . args . iter ( ) . map ( |t| t. clean ( ) ) . collect ( ) )
1219
+ }
1220
+ Some ( s) => {
1221
+ StructVariant ( VariantStruct {
1222
+ struct_type : doctree:: Plain ,
1223
+ fields_stripped : false ,
1224
+ fields : s. iter ( ) . zip ( self . args . iter ( ) ) . map ( |( name, ty) | {
1225
+ Item {
1226
+ source : Span :: empty ( ) ,
1227
+ name : Some ( name. clean ( ) ) ,
1228
+ attrs : Vec :: new ( ) ,
1229
+ visibility : Some ( ast:: Public ) ,
1230
+ def_id : self . id , // FIXME: this is not accurate
1231
+ inner : StructFieldItem (
1232
+ TypedStructField ( ty. clean ( ) )
1233
+ )
1234
+ }
1235
+ } ) . collect ( )
1236
+ } )
1237
+ }
1238
+ } ;
1239
+ Item {
1240
+ name : Some ( self . name . clean ( ) ) ,
1241
+ attrs : load_attrs ( tcx, self . id ) ,
1242
+ source : Span :: empty ( ) ,
1243
+ visibility : Some ( ast:: Public ) ,
1244
+ def_id : self . id ,
1245
+ inner : VariantItem ( Variant { kind : kind } ) ,
1246
+ }
1247
+ }
1248
+ }
1249
+
1207
1250
#[ deriving( Clone , Encodable , Decodable ) ]
1208
1251
pub enum VariantKind {
1209
1252
CLikeVariant ,
@@ -1524,6 +1567,10 @@ fn try_inline(id: ast::NodeId) -> Option<Vec<Item>> {
1524
1567
ret. extend ( build_impls ( tcx, did) . move_iter ( ) ) ;
1525
1568
StructItem ( build_struct ( tcx, did) )
1526
1569
}
1570
+ ast:: DefTy ( did) => {
1571
+ ret. extend ( build_impls ( tcx, did) . move_iter ( ) ) ;
1572
+ build_type ( tcx, did)
1573
+ }
1527
1574
_ => return None ,
1528
1575
} ;
1529
1576
let fqn = csearch:: get_item_path ( tcx, did) ;
@@ -1822,6 +1869,25 @@ fn build_struct(tcx: &ty::ctxt, did: ast::DefId) -> Struct {
1822
1869
}
1823
1870
}
1824
1871
1872
+ fn build_type ( tcx : & ty:: ctxt , did : ast:: DefId ) -> ItemEnum {
1873
+ let t = ty:: lookup_item_type ( tcx, did) ;
1874
+ match ty:: get ( t. ty ) . sty {
1875
+ ty:: ty_enum( edid, _) => {
1876
+ return EnumItem ( Enum {
1877
+ generics : t. generics . clean ( ) ,
1878
+ variants_stripped : false ,
1879
+ variants : ty:: enum_variants ( tcx, edid) . clean ( ) ,
1880
+ } )
1881
+ }
1882
+ _ => { }
1883
+ }
1884
+
1885
+ TypedefItem ( Typedef {
1886
+ type_ : t. ty . clean ( ) ,
1887
+ generics : t. generics . clean ( ) ,
1888
+ } )
1889
+ }
1890
+
1825
1891
fn build_impls ( tcx : & ty:: ctxt ,
1826
1892
did : ast:: DefId ) -> Vec < Item > {
1827
1893
ty:: populate_implementations_for_type_if_necessary ( tcx, did) ;
0 commit comments