Skip to content

Commit

Permalink
rustc: Encode metadata unconditionally for impls/traits/classes. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton committed Jul 18, 2012
1 parent c936ae5 commit 1528256
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/rustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ fn get_impls_for_mod(cdata: cmd,
do ebml::tagged_docs(mod_item, tag_mod_impl) |doc| {
let did = ebml::with_doc_data(doc, |d| parse_def_id(d));
let local_did = translate_def_id(cdata, did);
#debug("(get impls for mod) getting did %? for '%?'",
local_did, name);
// 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);
Expand Down
61 changes: 35 additions & 26 deletions src/rustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,32 +396,34 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
let impls = ecx.impl_map(id);
for impls.each |i| {
let (ident, did) = i;
#debug("(encoding info for module) ... encoding impl %s (%?), \
#debug("(encoding info for module) ... encoding impl %s (%?/%?), \
exported? %?",
*ident, did, ast_util::is_exported(ident, md));
if ast_util::is_exported(ident, md) {
ebml_w.start_tag(tag_mod_impl);
alt ecx.tcx.items.find(did.node) {
some(ast_map::node_item(it@@{node: cl@item_class(*),_},_)) {
/* If did stands for a trait
ref, we need to map it to its parent class */
ebml_w.wr_str(def_to_str(local_def(it.id)));
}
some(ast_map::node_item(@{node: item_impl(_,
some(ifce),_,_),_},_)) {
ebml_w.wr_str(def_to_str(did));
}
some(_) {
ebml_w.wr_str(def_to_str(did));
}
none {
// Must be a re-export, then!
// ...or an iface ref
ebml_w.wr_str(def_to_str(did));
}
};
ebml_w.end_tag();
} // if
*ident,
did,
ast_map::node_id_to_str(ecx.tcx.items, did.node),
ast_util::is_exported(ident, md));

ebml_w.start_tag(tag_mod_impl);
alt ecx.tcx.items.find(did.node) {
some(ast_map::node_item(it@@{node: cl@item_class(*),_},_)) {
/* If did stands for a trait
ref, we need to map it to its parent class */
ebml_w.wr_str(def_to_str(local_def(it.id)));
}
some(ast_map::node_item(@{node: item_impl(_,
some(ifce),_,_),_},_)) {
ebml_w.wr_str(def_to_str(did));
}
some(_) {
ebml_w.wr_str(def_to_str(did));
}
none {
// Must be a re-export, then!
// ...or an iface ref
ebml_w.wr_str(def_to_str(did));
}
};
ebml_w.end_tag();
} // for

encode_path(ebml_w, path, ast_map::path_mod(name));
Expand Down Expand Up @@ -552,7 +554,14 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,

let tcx = ecx.tcx;
let must_write =
alt item.node { item_enum(_, _) { true } _ { false } };
alt item.node {
item_enum(_, _) | item_impl(*) | item_trait(*) | item_class(*) {
true
}
_ {
false
}
};
if !must_write && !reachable(ecx, item.id) { ret; }

fn add_to_index_(item: @item, ebml_w: ebml::writer,
Expand Down

0 comments on commit 1528256

Please sign in to comment.