Skip to content

rustdoc miscellany #21368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 22, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ use util::nodemap::{FnvHashMap};
use arena::TypedArena;
use std::borrow::{BorrowFrom, Cow};
use std::cell::{Cell, RefCell};
use std::cmp::{self, Ordering};
use std::cmp;
use std::fmt::{self, Show};
use std::hash::{Hash, Writer, SipHasher, Hasher};
use std::mem;
Expand Down Expand Up @@ -5096,25 +5096,6 @@ pub fn associated_type_parameter_index(cx: &ctxt,
cx.sess.bug("couldn't find associated type parameter index")
}

#[derive(Copy, PartialEq, Eq)]
pub struct AssociatedTypeInfo {
pub def_id: ast::DefId,
pub index: uint,
pub name: ast::Name,
}

impl PartialOrd for AssociatedTypeInfo {
fn partial_cmp(&self, other: &AssociatedTypeInfo) -> Option<Ordering> {
Some(self.index.cmp(&other.index))
}
}

impl Ord for AssociatedTypeInfo {
fn cmp(&self, other: &AssociatedTypeInfo) -> Ordering {
self.index.cmp(&other.index)
}
}

pub fn trait_item_def_ids(cx: &ctxt, id: ast::DefId)
-> Rc<Vec<ImplOrTraitItemId>> {
lookup_locally_or_in_crate_store("trait_item_def_ids",
Expand Down
34 changes: 27 additions & 7 deletions src/librustdoc/clean/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,22 @@ pub fn record_extern_fqn(cx: &DocContext, did: ast::DefId, kind: clean::TypeKind

pub fn build_external_trait(cx: &DocContext, tcx: &ty::ctxt,
did: ast::DefId) -> clean::Trait {
use clean::TraitMethod;

let def = ty::lookup_trait_def(tcx, did);
let trait_items = ty::trait_items(tcx, did).clean(cx);
let provided = ty::provided_trait_methods(tcx, did);
let items = trait_items.into_iter().map(|trait_item| {
if provided.iter().any(|a| a.def_id == trait_item.def_id) {
clean::ProvidedMethod(trait_item)
} else {
clean::RequiredMethod(trait_item)
match trait_item.inner {
clean::TyMethodItem(_) => {
if provided.iter().any(|a| a.def_id == trait_item.def_id) {
TraitMethod::ProvidedMethod(trait_item)
} else {
TraitMethod::RequiredMethod(trait_item)
}
},
clean::AssociatedTypeItem(_) => TraitMethod::TypeTraitItem(trait_item),
_ => unreachable!()
}
});
let trait_def = ty::lookup_trait_def(tcx, did);
Expand Down Expand Up @@ -311,9 +319,21 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt,
};
Some(item)
}
ty::TypeTraitItem(_) => {
// FIXME(pcwalton): Implement.
None
ty::TypeTraitItem(ref assoc_ty) => {
let did = assoc_ty.def_id;
let type_scheme = ty::lookup_item_type(tcx, did);
// Not sure the choice of ParamSpace actually matters here, because an
// associated type won't have generics on the LHS
let typedef = (type_scheme, subst::ParamSpace::TypeSpace).clean(cx);
Some(clean::Item {
name: Some(assoc_ty.name.clean(cx)),
inner: clean::TypedefItem(typedef),
source: clean::Span::empty(),
attrs: vec![],
visibility: None,
stability: stability::lookup(tcx, did).clean(cx),
def_id: did
})
}
}
}).collect();
Expand Down
Loading