about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-07-18 14:41:31 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-07-18 14:43:16 -0700
commit1528256fdc26199dd58b390e42e2d0dc53b9703d (patch)
tree687ad465aa1fe4026f7448322e0718b6cee62d2e
parentc936ae515bdcebd184309c709540b512fc6f7c59 (diff)
downloadrust-1528256fdc26199dd58b390e42e2d0dc53b9703d.tar.gz
rust-1528256fdc26199dd58b390e42e2d0dc53b9703d.zip
rustc: Encode metadata unconditionally for impls/traits/classes. Closes #2945.
-rw-r--r--src/rustc/metadata/decoder.rs2
-rw-r--r--src/rustc/metadata/encoder.rs61
2 files changed, 37 insertions, 26 deletions
diff --git a/src/rustc/metadata/decoder.rs b/src/rustc/metadata/decoder.rs
index c9b214134a7..970be7ea53f 100644
--- a/src/rustc/metadata/decoder.rs
+++ b/src/rustc/metadata/decoder.rs
@@ -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);
diff --git a/src/rustc/metadata/encoder.rs b/src/rustc/metadata/encoder.rs
index d1ecf88b3fe..4df1e0aa513 100644
--- a/src/rustc/metadata/encoder.rs
+++ b/src/rustc/metadata/encoder.rs
@@ -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));
@@ -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,