diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs index c897767d2b7..a01af9c6c7f 100644 --- a/src/rustc/metadata/encoder.rs +++ b/src/rustc/metadata/encoder.rs @@ -2,7 +2,7 @@ import util::ppaux::ty_to_str; -import std::{ebml, map, list}; +import std::{ebml, map}; import std::map::hashmap; import io::writer_util; import ebml::writer; @@ -17,7 +17,6 @@ import middle::ast_map; import syntax::attr; import std::serialization::serializer; import std::ebml::serializer; -import middle::resolve; import syntax::ast; import syntax::diagnostic::span_handler; @@ -49,7 +48,7 @@ type encode_parms = { tcx: ty::ctxt, reachable: hashmap, reexports: [(str, def_id)], - impl_map: resolve::impl_map, + impl_map: fn@(ast::node_id) -> [(ident, def_id)], item_symbols: hashmap, discrim_symbols: hashmap, link_meta: link_meta, @@ -62,7 +61,7 @@ enum encode_ctxt = { tcx: ty::ctxt, reachable: hashmap, reexports: [(str, def_id)], - impl_map: resolve::impl_map, + impl_map: fn@(ast::node_id) -> [(ident, def_id)], item_symbols: hashmap, discrim_symbols: hashmap, link_meta: link_meta, @@ -405,36 +404,31 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod, encode_def_id(ebml_w, local_def(id)); encode_family(ebml_w, 'm'); encode_name(ebml_w, name); - alt ecx.impl_map.get(id) { - list::cons(impls, @list::nil) { - for vec::each(*impls) {|i| - if ast_util::is_exported(i.ident, md) { - ebml_w.start_tag(tag_mod_impl); + let impls = ecx.impl_map(id); + for impls.each {|i| + let (ident, did) = i; + if ast_util::is_exported(ident, md) { + ebml_w.start_tag(tag_mod_impl); /* If did stands for an iface - ref, we need to map it to its parent class */ - alt ecx.tcx.items.get(i.did.node) { - ast_map::node_item(it@@{node: cl@item_class(*),_},_) { - ebml_w.wr_str(def_to_str(local_def(it.id))); - some(ty::lookup_item_type(ecx.tcx, i.did).ty) - } - ast_map::node_item(@{node: item_impl(_,_, - some(ifce),_,_),_},_) { - ebml_w.wr_str(def_to_str(i.did)); - some(ty::node_id_to_type(ecx.tcx, ifce.id)) - } - _ { - ebml_w.wr_str(def_to_str(i.did)); none - } - }; - ebml_w.end_tag(); - } // if - } // for - } // list::cons alt - _ { - ecx.diag.handler().bug(#fmt("encode_info_for_mod: empty impl_map \ - entry for %?", path)); - } - } + ref, we need to map it to its parent class */ + alt ecx.tcx.items.get(did.node) { + ast_map::node_item(it@@{node: cl@item_class(*),_},_) { + ebml_w.wr_str(def_to_str(local_def(it.id))); + some(ty::lookup_item_type(ecx.tcx, did).ty) + } + ast_map::node_item(@{node: item_impl(_,_, + some(ifce),_,_),_},_) { + ebml_w.wr_str(def_to_str(did)); + some(ty::node_id_to_type(ecx.tcx, ifce.id)) + } + _ { + ebml_w.wr_str(def_to_str(did)); none + } + }; + ebml_w.end_tag(); + } // if + } // for + encode_path(ebml_w, path, ast_map::path_mod(name)); ebml_w.end_tag(); } diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 41c065bb025..1d8355bffbf 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -14,7 +14,7 @@ // int) and rec(x=int, y=int, z=int) will have the same TypeRef. import libc::c_uint; -import std::{map, time}; +import std::{map, time, list}; import std::map::hashmap; import std::map::{int_hash, str_hash}; import driver::session; @@ -5202,7 +5202,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) tcx: cx.tcx, reachable: cx.reachable, reexports: reexports(cx), - impl_map: cx.maps.impl_map, + impl_map: impl_map(cx, _), item_symbols: cx.item_symbols, discrim_symbols: cx.discrim_symbols, link_meta: cx.link_meta, @@ -5226,6 +5226,20 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt) ret reexports; } + fn impl_map(cx: @crate_ctxt, + id: ast::node_id) -> [(ast::ident, ast::def_id)] { + alt cx.maps.impl_map.get(id) { + list::cons(impls, @list::nil) { + (*impls).map {|i| + (i.ident, i.did) + } + } + _ { + cx.sess.bug(#fmt("encode_info_for_mod: empty impl_map \ + entry for %?", id)); + } + } + } } fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {