rustc: rename ty::populate_implementations_for_type_if_necessary to make it clear that it only populates inherent impls.
This commit is contained in:
parent
8bcb3cb475
commit
aeb92bab5d
@ -313,13 +313,13 @@ pub fn each_impl<F>(cstore: &cstore::CStore,
|
||||
decoder::each_impl(&*cdata, callback)
|
||||
}
|
||||
|
||||
pub fn each_implementation_for_type<F>(cstore: &cstore::CStore,
|
||||
def_id: ast::DefId,
|
||||
callback: F) where
|
||||
pub fn each_inherent_implementation_for_type<F>(cstore: &cstore::CStore,
|
||||
def_id: ast::DefId,
|
||||
callback: F) where
|
||||
F: FnMut(ast::DefId),
|
||||
{
|
||||
let cdata = cstore.get_crate_data(def_id.krate);
|
||||
decoder::each_implementation_for_type(&*cdata, def_id.node, callback)
|
||||
decoder::each_inherent_implementation_for_type(&*cdata, def_id.node, callback)
|
||||
}
|
||||
|
||||
pub fn each_implementation_for_trait<F>(cstore: &cstore::CStore,
|
||||
|
@ -1338,17 +1338,18 @@ pub fn each_impl<F>(cdata: Cmd, mut callback: F) where
|
||||
});
|
||||
}
|
||||
|
||||
pub fn each_implementation_for_type<F>(cdata: Cmd,
|
||||
id: ast::NodeId,
|
||||
mut callback: F)
|
||||
pub fn each_inherent_implementation_for_type<F>(cdata: Cmd,
|
||||
id: ast::NodeId,
|
||||
mut callback: F)
|
||||
where F: FnMut(ast::DefId),
|
||||
{
|
||||
let item_doc = lookup_item(id, cdata.data());
|
||||
reader::tagged_docs(item_doc,
|
||||
tag_items_data_item_inherent_impl,
|
||||
|impl_doc| {
|
||||
let implementation_def_id = item_def_id(impl_doc, cdata);
|
||||
callback(implementation_def_id);
|
||||
if reader::maybe_get_doc(impl_doc, tag_item_trait_ref).is_none() {
|
||||
callback(item_def_id(impl_doc, cdata));
|
||||
}
|
||||
true
|
||||
});
|
||||
}
|
||||
|
@ -6336,10 +6336,10 @@ pub fn populate_implementations_for_primitive_if_necessary(tcx: &ctxt,
|
||||
tcx.populated_external_primitive_impls.borrow_mut().insert(primitive_def_id);
|
||||
}
|
||||
|
||||
/// Populates the type context with all the implementations for the given type
|
||||
/// if necessary.
|
||||
pub fn populate_implementations_for_type_if_necessary(tcx: &ctxt,
|
||||
type_id: ast::DefId) {
|
||||
/// Populates the type context with all the inherent implementations for
|
||||
/// the given type if necessary.
|
||||
pub fn populate_inherent_implementations_for_type_if_necessary(tcx: &ctxt,
|
||||
type_id: ast::DefId) {
|
||||
if type_id.krate == LOCAL_CRATE {
|
||||
return
|
||||
}
|
||||
@ -6348,37 +6348,15 @@ pub fn populate_implementations_for_type_if_necessary(tcx: &ctxt,
|
||||
return
|
||||
}
|
||||
|
||||
debug!("populate_implementations_for_type_if_necessary: searching for {:?}", type_id);
|
||||
debug!("populate_inherent_implementations_for_type_if_necessary: searching for {:?}", type_id);
|
||||
|
||||
let mut inherent_impls = Vec::new();
|
||||
csearch::each_implementation_for_type(&tcx.sess.cstore, type_id, |impl_def_id| {
|
||||
let impl_items = csearch::get_impl_items(&tcx.sess.cstore, impl_def_id);
|
||||
|
||||
// Record the implementation, if needed
|
||||
if let Some(trait_ref) = csearch::get_impl_trait(tcx, impl_def_id) {
|
||||
let trait_def = lookup_trait_def(tcx, trait_ref.def_id);
|
||||
trait_def.record_impl(tcx, impl_def_id, trait_ref);
|
||||
} else {
|
||||
inherent_impls.push(impl_def_id);
|
||||
}
|
||||
|
||||
// For any methods that use a default implementation, add them to
|
||||
// the map. This is a bit unfortunate.
|
||||
for impl_item_def_id in &impl_items {
|
||||
let method_def_id = impl_item_def_id.def_id();
|
||||
match impl_or_trait_item(tcx, method_def_id) {
|
||||
MethodTraitItem(method) => {
|
||||
if let Some(source) = method.provided_source {
|
||||
tcx.provided_method_sources
|
||||
.borrow_mut()
|
||||
.insert(method_def_id, source);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
csearch::each_inherent_implementation_for_type(&tcx.sess.cstore, type_id, |impl_def_id| {
|
||||
// Record the implementation.
|
||||
inherent_impls.push(impl_def_id);
|
||||
|
||||
// Store the implementation info.
|
||||
let impl_items = csearch::get_impl_items(&tcx.sess.cstore, impl_def_id);
|
||||
tcx.impl_items.borrow_mut().insert(impl_def_id, impl_items);
|
||||
});
|
||||
|
||||
|
@ -371,7 +371,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
|
||||
fn assemble_inherent_impl_candidates_for_type(&mut self, def_id: ast::DefId) {
|
||||
// Read the inherent implementation candidates for this type from the
|
||||
// metadata if necessary.
|
||||
ty::populate_implementations_for_type_if_necessary(self.tcx(), def_id);
|
||||
ty::populate_inherent_implementations_for_type_if_necessary(self.tcx(), def_id);
|
||||
|
||||
if let Some(impl_infos) = self.tcx().inherent_impls.borrow().get(&def_id) {
|
||||
for &impl_def_id in &***impl_infos {
|
||||
|
@ -221,7 +221,7 @@ fn build_type(cx: &DocContext, tcx: &ty::ctxt, did: ast::DefId) -> clean::ItemEn
|
||||
|
||||
pub fn build_impls(cx: &DocContext, tcx: &ty::ctxt,
|
||||
did: ast::DefId) -> Vec<clean::Item> {
|
||||
ty::populate_implementations_for_type_if_necessary(tcx, did);
|
||||
ty::populate_inherent_implementations_for_type_if_necessary(tcx, did);
|
||||
let mut impls = Vec::new();
|
||||
|
||||
match tcx.inherent_impls.borrow().get(&did) {
|
||||
|
Loading…
Reference in New Issue
Block a user