Skip to content

Commit eca94c1

Browse files
author
Ariel Ben-Yehuda
committed
make rustdoc work
1 parent 63be9d7 commit eca94c1

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

src/librustc_privacy/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for PrivacyVisitor<'a, 'tcx> {
927927
});
928928
if any_priv {
929929
self.tcx.sess.span_err(expr.span,
930-
"cannot invoke tuple struct construcor \
930+
"cannot invoke tuple struct constructor \
931931
with private fields");
932932
}
933933
}

src/librustdoc/clean/inline.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,17 @@ fn build_struct(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::Stru
185185

186186
let t = tcx.lookup_item_type(did);
187187
let predicates = tcx.lookup_predicates(did);
188-
let fields = tcx.lookup_struct_fields(did);
188+
let variant = tcx.lookup_adt_def(did).struct_variant();
189189

190190
clean::Struct {
191-
struct_type: match &*fields {
191+
struct_type: match &*variant.fields {
192192
[] => doctree::Unit,
193193
[ref f] if f.name == unnamed_field.name => doctree::Newtype,
194194
[ref f, ..] if f.name == unnamed_field.name => doctree::Tuple,
195195
_ => doctree::Plain,
196196
},
197197
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
198-
fields: fields.clean(cx),
198+
fields: variant.fields.clean(cx),
199199
fields_stripped: false,
200200
}
201201
}
@@ -208,7 +208,7 @@ fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEn
208208
return clean::EnumItem(clean::Enum {
209209
generics: (&t.generics, &predicates, subst::TypeSpace).clean(cx),
210210
variants_stripped: false,
211-
variants: tcx.enum_variants(edef.did).clean(cx),
211+
variants: edef.variants.clean(cx),
212212
})
213213
}
214214
_ => {}

src/librustdoc/clean/mod.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,29 +1730,27 @@ impl Clean<Item> for ast::StructField {
17301730
}
17311731
}
17321732

1733-
impl Clean<Item> for ty::FieldTy {
1733+
impl<'tcx> Clean<Item> for ty::FieldDef<'tcx> {
17341734
fn clean(&self, cx: &DocContext) -> Item {
17351735
use syntax::parse::token::special_idents::unnamed_field;
17361736
use rustc::metadata::csearch;
17371737

1738-
let attr_map = csearch::get_struct_field_attrs(&cx.tcx().sess.cstore, self.id);
1738+
let attr_map = csearch::get_struct_field_attrs(&cx.tcx().sess.cstore, self.did);
17391739

17401740
let (name, attrs) = if self.name == unnamed_field.name {
17411741
(None, None)
17421742
} else {
1743-
(Some(self.name), Some(attr_map.get(&self.id.node).unwrap()))
1743+
(Some(self.name), Some(attr_map.get(&self.did.node).unwrap()))
17441744
};
17451745

1746-
let ty = cx.tcx().lookup_item_type(self.id);
1747-
17481746
Item {
17491747
name: name.clean(cx),
17501748
attrs: attrs.unwrap_or(&Vec::new()).clean(cx),
17511749
source: Span::empty(),
17521750
visibility: Some(self.vis),
1753-
stability: get_stability(cx, self.id),
1754-
def_id: self.id,
1755-
inner: StructFieldItem(TypedStructField(ty.ty.clean(cx))),
1751+
stability: get_stability(cx, self.did),
1752+
def_id: self.did,
1753+
inner: StructFieldItem(TypedStructField(self.unsubst_ty().clean(cx))),
17561754
}
17571755
}
17581756
}
@@ -1858,22 +1856,24 @@ impl Clean<Item> for doctree::Variant {
18581856
}
18591857
}
18601858

1861-
impl<'tcx> Clean<Item> for ty::VariantInfo<'tcx> {
1859+
impl<'tcx> Clean<Item> for ty::VariantDef<'tcx> {
18621860
fn clean(&self, cx: &DocContext) -> Item {
18631861
// use syntax::parse::token::special_idents::unnamed_field;
1864-
let kind = match self.arg_names.as_ref().map(|s| &**s) {
1865-
None | Some([]) if self.args.is_empty() => CLikeVariant,
1866-
None | Some([]) => {
1867-
TupleVariant(self.args.clean(cx))
1862+
let kind = match self.kind() {
1863+
ty::VariantKind::Unit => CLikeVariant,
1864+
ty::VariantKind::Tuple => {
1865+
TupleVariant(
1866+
self.fields.iter().map(|f| f.unsubst_ty().clean(cx)).collect()
1867+
)
18681868
}
1869-
Some(s) => {
1869+
ty::VariantKind::Dict => {
18701870
StructVariant(VariantStruct {
18711871
struct_type: doctree::Plain,
18721872
fields_stripped: false,
1873-
fields: s.iter().zip(&self.args).map(|(name, ty)| {
1873+
fields: self.fields.iter().map(|field| {
18741874
Item {
18751875
source: Span::empty(),
1876-
name: Some(name.clean(cx)),
1876+
name: Some(field.name.clean(cx)),
18771877
attrs: Vec::new(),
18781878
visibility: Some(ast::Public),
18791879
// FIXME: this is not accurate, we need an id for
@@ -1883,10 +1883,10 @@ impl<'tcx> Clean<Item> for ty::VariantInfo<'tcx> {
18831883
// Struct variants are experimental and need
18841884
// more infrastructure work before we can get
18851885
// at the needed information here.
1886-
def_id: self.id,
1887-
stability: get_stability(cx, self.id),
1886+
def_id: self.did,
1887+
stability: get_stability(cx, self.did),
18881888
inner: StructFieldItem(
1889-
TypedStructField(ty.clean(cx))
1889+
TypedStructField(field.unsubst_ty().clean(cx))
18901890
)
18911891
}
18921892
}).collect()
@@ -1895,12 +1895,12 @@ impl<'tcx> Clean<Item> for ty::VariantInfo<'tcx> {
18951895
};
18961896
Item {
18971897
name: Some(self.name.clean(cx)),
1898-
attrs: inline::load_attrs(cx, cx.tcx(), self.id),
1898+
attrs: inline::load_attrs(cx, cx.tcx(), self.did),
18991899
source: Span::empty(),
19001900
visibility: Some(ast::Public),
1901-
def_id: self.id,
1901+
def_id: self.did,
19021902
inner: VariantItem(Variant { kind: kind }),
1903-
stability: get_stability(cx, self.id),
1903+
stability: get_stability(cx, self.did),
19041904
}
19051905
}
19061906
}

0 commit comments

Comments
 (0)