about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rustc/middle/trans/reachable.rs20
-rw-r--r--src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs28
-rw-r--r--src/test/run-pass/crate-method-reexport-grrrrrrr.rs15
3 files changed, 49 insertions, 14 deletions
diff --git a/src/rustc/middle/trans/reachable.rs b/src/rustc/middle/trans/reachable.rs
index 51dc20d1c87..39e0461dee6 100644
--- a/src/rustc/middle/trans/reachable.rs
+++ b/src/rustc/middle/trans/reachable.rs
@@ -27,7 +27,7 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve::exp_map,
     let rmap = std::map::int_hash();
     let cx = {exp_map: exp_map, tcx: tcx, method_map: method_map, rmap: rmap};
     traverse_public_mod(cx, crate_mod);
-    traverse_all_resources(cx, crate_mod);
+    traverse_all_resources_and_impls(cx, crate_mod);
     rmap
 }
 
@@ -81,18 +81,6 @@ fn traverse_public_mod(cx: ctx, m: _mod) {
     if !traverse_exports(cx, m.view_items) {
         // No exports, so every local item is exported
         for vec::each(m.items) |item| { traverse_public_item(cx, item); }
-    } else {
-        // Make impls always reachable.
-        for vec::each(m.items) |item| {
-            alt item.node {
-                item_impl(*) {
-                    traverse_public_item(cx, item);
-                }
-                _ {
-                    // Nothing to do.
-                }
-            }
-        }
     }
 }
 
@@ -212,7 +200,7 @@ fn traverse_inline_body(cx: ctx, body: blk) {
     }));
 }
 
-fn traverse_all_resources(cx: ctx, crate_mod: _mod) {
+fn traverse_all_resources_and_impls(cx: ctx, crate_mod: _mod) {
     visit::visit_mod(crate_mod, ast_util::dummy_sp(), 0, cx, visit::mk_vt(@{
         visit_expr: |_e, _cx, _v| { },
         visit_item: |i, cx, v| {
@@ -221,9 +209,13 @@ fn traverse_all_resources(cx: ctx, crate_mod: _mod) {
               item_class(_, _, _, _, some(_)) {
                 traverse_public_item(cx, i);
               }
+              item_impl(*) {
+                traverse_public_item(cx, i);
+              }
               _ {}
             }
         }
         with *visit::default_visitor()
     }));
 }
+
diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs
new file mode 100644
index 00000000000..eae7bf8e7cb
--- /dev/null
+++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs
@@ -0,0 +1,28 @@
+#[link(name = "crate_method_reexport_grrrrrrr2")];
+
+export rust;
+
+import name_pool::methods;
+
+mod name_pool {
+
+    type name_pool = ();
+
+    impl methods for name_pool {
+        fn add(s: str) {
+        }
+    }
+}
+
+mod rust {
+
+    export rt;
+    export methods;
+
+    type rt = @();
+
+    impl methods for rt {
+        fn cx() {
+        }
+    }
+}
diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs
new file mode 100644
index 00000000000..0482516d38f
--- /dev/null
+++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs
@@ -0,0 +1,15 @@
+// This is a regression test that the metadata for the
+// name_pool::methods impl in the other crate is reachable from this
+// crate.
+
+// aux-build:crate-method-reexport-grrrrrrr2.rs
+
+use crate_method_reexport_grrrrrrr2;
+
+fn main() {
+    import crate_method_reexport_grrrrrrr2::rust::methods;
+    let x = @();
+    x.cx();
+    let y = ();
+    y.add("hi");
+}
\ No newline at end of file