Skip to content

Commit e83564e

Browse files
committed
---
yaml --- r: 152014 b: refs/heads/try2 c: 622c8f7 h: refs/heads/master v: v3
1 parent 8f46be0 commit e83564e

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c81b511bfdbb5f0fb2a6c7522cf4b8dbe5c83ece
8+
refs/heads/try2: 622c8f7b57b70a61dc5c9a4b288ce5bf2ff8ac04
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustdoc/clean.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,49 @@ impl Clean<Item> for doctree::Variant {
12041204
}
12051205
}
12061206

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+
12071250
#[deriving(Clone, Encodable, Decodable)]
12081251
pub enum VariantKind {
12091252
CLikeVariant,
@@ -1524,6 +1567,10 @@ fn try_inline(id: ast::NodeId) -> Option<Vec<Item>> {
15241567
ret.extend(build_impls(tcx, did).move_iter());
15251568
StructItem(build_struct(tcx, did))
15261569
}
1570+
ast::DefTy(did) => {
1571+
ret.extend(build_impls(tcx, did).move_iter());
1572+
build_type(tcx, did)
1573+
}
15271574
_ => return None,
15281575
};
15291576
let fqn = csearch::get_item_path(tcx, did);
@@ -1822,6 +1869,25 @@ fn build_struct(tcx: &ty::ctxt, did: ast::DefId) -> Struct {
18221869
}
18231870
}
18241871

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+
18251891
fn build_impls(tcx: &ty::ctxt,
18261892
did: ast::DefId) -> Vec<Item> {
18271893
ty::populate_implementations_for_type_if_necessary(tcx, did);

0 commit comments

Comments
 (0)