}
ast::DefStruct(did) => {
record_extern_fqn(cx, did, clean::TypeStruct);
- ret.extend(build_impls(tcx, did).move_iter());
+ ret.extend(build_impls(cx, tcx, did).move_iter());
clean::StructItem(build_struct(tcx, did))
}
ast::DefTy(did) => {
record_extern_fqn(cx, did, clean::TypeEnum);
- ret.extend(build_impls(tcx, did).move_iter());
+ ret.extend(build_impls(cx, tcx, did).move_iter());
build_type(tcx, did)
}
// Assume that the enum type is reexported next to the variant, and
})
}
-fn build_impls(tcx: &ty::ctxt,
+fn build_impls(cx: &core::DocContext,
+ tcx: &ty::ctxt,
did: ast::DefId) -> Vec<clean::Item> {
ty::populate_implementations_for_type_if_necessary(tcx, did);
let mut impls = Vec::new();
}
}
+ // If this is the first time we've inlined something from this crate, then
+ // we inline *all* impls from the crate into this crate. Note that there's
+ // currently no way for us to filter this based on type, and we likely need
+ // many impls for a variety of reasons.
+ //
+ // Primarily, the impls will be used to populate the documentation for this
+ // type being inlined, but impls can also be used when generating
+ // documentation for primitives (no way to find those specifically).
+ if cx.populated_crate_impls.borrow_mut().insert(did.krate) {
+ csearch::each_top_level_item_of_crate(&tcx.sess.cstore,
+ did.krate,
+ |def, _, _| {
+ populate_impls(tcx, def, &mut impls)
+ });
+
+ fn populate_impls(tcx: &ty::ctxt,
+ def: decoder::DefLike,
+ impls: &mut Vec<clean::Item>) {
+ match def {
+ decoder::DlImpl(did) => impls.push(build_impl(tcx, did)),
+ decoder::DlDef(ast::DefMod(did)) => {
+ csearch::each_child_of_item(&tcx.sess.cstore,
+ did,
+ |def, _, _| {
+ populate_impls(tcx, def, impls)
+ })
+ }
+ _ => {}
+ }
+ }
+ }
+
impls
}
None => {}
}
}
- decoder::DlImpl(did) => items.push(build_impl(tcx, did)),
+ // All impls were inlined above
+ decoder::DlImpl(..) => {}
decoder::DlField => fail!("unimplemented field"),
}
});
pub external_traits: RefCell<Option<HashMap<ast::DefId, clean::Trait>>>,
pub external_typarams: RefCell<Option<HashMap<ast::DefId, String>>>,
pub inlined: RefCell<Option<HashSet<ast::DefId>>>,
+ pub populated_crate_impls: RefCell<HashSet<ast::CrateNum>>,
}
impl DocContext {
external_typarams: RefCell::new(Some(HashMap::new())),
external_paths: RefCell::new(Some(HashMap::new())),
inlined: RefCell::new(Some(HashSet::new())),
+ populated_crate_impls: RefCell::new(HashSet::new()),
}, CrateAnalysis {
exported_items: exported_items,
public_items: public_items,