Skip to content

Commit 5fda9bc

Browse files
committed
rollup merge of #21368: tomjakubowski/rustdoc-miscellany
Conflicts: src/librustdoc/clean/mod.rs
2 parents ecc9dcc + 159236a commit 5fda9bc

File tree

6 files changed

+95
-72
lines changed

6 files changed

+95
-72
lines changed

src/librustc/middle/ty.rs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use util::nodemap::{FnvHashMap};
7070
use arena::TypedArena;
7171
use std::borrow::{BorrowFrom, Cow};
7272
use std::cell::{Cell, RefCell};
73-
use std::cmp::{self, Ordering};
73+
use std::cmp;
7474
use std::fmt::{self, Show};
7575
use std::hash::{Hash, Writer, SipHasher, Hasher};
7676
use std::mem;
@@ -5089,25 +5089,6 @@ pub fn associated_type_parameter_index(cx: &ctxt,
50895089
cx.sess.bug("couldn't find associated type parameter index")
50905090
}
50915091

5092-
#[derive(Copy, PartialEq, Eq)]
5093-
pub struct AssociatedTypeInfo {
5094-
pub def_id: ast::DefId,
5095-
pub index: uint,
5096-
pub name: ast::Name,
5097-
}
5098-
5099-
impl PartialOrd for AssociatedTypeInfo {
5100-
fn partial_cmp(&self, other: &AssociatedTypeInfo) -> Option<Ordering> {
5101-
Some(self.index.cmp(&other.index))
5102-
}
5103-
}
5104-
5105-
impl Ord for AssociatedTypeInfo {
5106-
fn cmp(&self, other: &AssociatedTypeInfo) -> Ordering {
5107-
self.index.cmp(&other.index)
5108-
}
5109-
}
5110-
51115092
pub fn trait_item_def_ids(cx: &ctxt, id: ast::DefId)
51125093
-> Rc<Vec<ImplOrTraitItemId>> {
51135094
lookup_locally_or_in_crate_store("trait_item_def_ids",

src/librustdoc/clean/inline.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,22 @@ pub fn record_extern_fqn(cx: &DocContext, did: ast::DefId, kind: clean::TypeKind
147147

148148
pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
149149
did: ast::DefId) -> clean::Trait {
150+
use clean::TraitMethod;
151+
150152
let def = ty::lookup_trait_def(tcx, did);
151153
let trait_items = ty::trait_items(tcx, did).clean(cx);
152154
let provided = ty::provided_trait_methods(tcx, did);
153155
let items = trait_items.into_iter().map(|trait_item| {
154-
if provided.iter().any(|a| a.def_id == trait_item.def_id) {
155-
clean::ProvidedMethod(trait_item)
156-
} else {
157-
clean::RequiredMethod(trait_item)
156+
match trait_item.inner {
157+
clean::TyMethodItem(_) => {
158+
if provided.iter().any(|a| a.def_id == trait_item.def_id) {
159+
TraitMethod::ProvidedMethod(trait_item)
160+
} else {
161+
TraitMethod::RequiredMethod(trait_item)
162+
}
163+
},
164+
clean::AssociatedTypeItem(_) => TraitMethod::TypeTraitItem(trait_item),
165+
_ => unreachable!()
158166
}
159167
});
160168
let trait_def = ty::lookup_trait_def(tcx, did);
@@ -311,9 +319,21 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
311319
};
312320
Some(item)
313321
}
314-
ty::TypeTraitItem(_) => {
315-
// FIXME(pcwalton): Implement.
316-
None
322+
ty::TypeTraitItem(ref assoc_ty) => {
323+
let did = assoc_ty.def_id;
324+
let type_scheme = ty::lookup_item_type(tcx, did);
325+
// Not sure the choice of ParamSpace actually matters here, because an
326+
// associated type won't have generics on the LHS
327+
let typedef = (type_scheme, subst::ParamSpace::TypeSpace).clean(cx);
328+
Some(clean::Item {
329+
name: Some(assoc_ty.name.clean(cx)),
330+
inner: clean::TypedefItem(typedef),
331+
source: clean::Span::empty(),
332+
attrs: vec![],
333+
visibility: None,
334+
stability: stability::lookup(tcx, did).clean(cx),
335+
def_id: did
336+
})
317337
}
318338
}
319339
}).collect();

0 commit comments

Comments
 (0)