rustc: Resolve external impls defined in yet other crates. Issue #2196
This commit is contained in:
parent
c461fc869c
commit
dea8ae4e6f
src/rustc/metadata
@ -116,7 +116,9 @@ fn get_impls_for_mod(cstore: cstore::cstore, def: ast::def_id,
|
||||
name: option<ast::ident>)
|
||||
-> @[@middle::resolve::_impl] {
|
||||
let cdata = cstore::get_crate_data(cstore, def.crate);
|
||||
decoder::get_impls_for_mod(cdata, def.node, name)
|
||||
decoder::get_impls_for_mod(cdata, def.node, name) {|cnum|
|
||||
cstore::get_crate_data(cstore, cnum)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_iface_methods(tcx: ty::ctxt, def: ast::def_id) -> @[ty::method] {
|
||||
|
@ -397,18 +397,27 @@ fn item_impl_methods(cdata: cmd, item: ebml::doc, base_tps: uint)
|
||||
}
|
||||
|
||||
fn get_impls_for_mod(cdata: cmd, m_id: ast::node_id,
|
||||
name: option<ast::ident>)
|
||||
name: option<ast::ident>,
|
||||
get_cdata: fn(ast::crate_num) -> cmd)
|
||||
-> @[@middle::resolve::_impl] {
|
||||
let data = cdata.data;
|
||||
let mod_item = lookup_item(m_id, data);
|
||||
let mut result = [];
|
||||
ebml::tagged_docs(mod_item, tag_mod_impl) {|doc|
|
||||
let did = translate_def_id(cdata, parse_def_id(ebml::doc_data(doc)));
|
||||
let item = lookup_item(did.node, data), nm = item_name(item);
|
||||
let did = parse_def_id(ebml::doc_data(doc));
|
||||
let local_did = translate_def_id(cdata, did);
|
||||
// The impl may be defined in a different crate. Ask the caller
|
||||
// to give us the metadata
|
||||
let impl_cdata = get_cdata(local_did.crate);
|
||||
let impl_data = impl_cdata.data;
|
||||
let item = lookup_item(local_did.node, impl_data);
|
||||
let nm = item_name(item);
|
||||
if alt name { some(n) { n == nm } none { true } } {
|
||||
let base_tps = item_ty_param_count(item);
|
||||
result += [@{did: did, ident: nm,
|
||||
methods: item_impl_methods(cdata, item, base_tps)}];
|
||||
result += [@{
|
||||
did: local_did, ident: nm,
|
||||
methods: item_impl_methods(impl_cdata, item, base_tps)
|
||||
}];
|
||||
}
|
||||
}
|
||||
@result
|
||||
|
Loading…
Reference in New Issue
Block a user