Skip to content

Commit 46fba10

Browse files
committed
rustc: Make all impls even more reachable
With this we write metadata for all impls so that we can properly find reexported impls.
1 parent 200a2de commit 46fba10

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

src/rustc/middle/trans/reachable.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve::exp_map,
2727
let rmap = std::map::int_hash();
2828
let cx = {exp_map: exp_map, tcx: tcx, method_map: method_map, rmap: rmap};
2929
traverse_public_mod(cx, crate_mod);
30-
traverse_all_resources(cx, crate_mod);
30+
traverse_all_resources_and_impls(cx, crate_mod);
3131
rmap
3232
}
3333

@@ -81,18 +81,6 @@ fn traverse_public_mod(cx: ctx, m: _mod) {
8181
if !traverse_exports(cx, m.view_items) {
8282
// No exports, so every local item is exported
8383
for vec::each(m.items) |item| { traverse_public_item(cx, item); }
84-
} else {
85-
// Make impls always reachable.
86-
for vec::each(m.items) |item| {
87-
alt item.node {
88-
item_impl(*) {
89-
traverse_public_item(cx, item);
90-
}
91-
_ {
92-
// Nothing to do.
93-
}
94-
}
95-
}
9684
}
9785
}
9886

@@ -212,7 +200,7 @@ fn traverse_inline_body(cx: ctx, body: blk) {
212200
}));
213201
}
214202

215-
fn traverse_all_resources(cx: ctx, crate_mod: _mod) {
203+
fn traverse_all_resources_and_impls(cx: ctx, crate_mod: _mod) {
216204
visit::visit_mod(crate_mod, ast_util::dummy_sp(), 0, cx, visit::mk_vt(@{
217205
visit_expr: |_e, _cx, _v| { },
218206
visit_item: |i, cx, v| {
@@ -221,9 +209,13 @@ fn traverse_all_resources(cx: ctx, crate_mod: _mod) {
221209
item_class(_, _, _, _, some(_)) {
222210
traverse_public_item(cx, i);
223211
}
212+
item_impl(*) {
213+
traverse_public_item(cx, i);
214+
}
224215
_ {}
225216
}
226217
}
227218
with *visit::default_visitor()
228219
}));
229220
}
221+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#[link(name = "crate_method_reexport_grrrrrrr2")];
2+
3+
export rust;
4+
5+
import name_pool::methods;
6+
7+
mod name_pool {
8+
9+
type name_pool = ();
10+
11+
impl methods for name_pool {
12+
fn add(s: str) {
13+
}
14+
}
15+
}
16+
17+
mod rust {
18+
19+
export rt;
20+
export methods;
21+
22+
type rt = @();
23+
24+
impl methods for rt {
25+
fn cx() {
26+
}
27+
}
28+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This is a regression test that the metadata for the
2+
// name_pool::methods impl in the other crate is reachable from this
3+
// crate.
4+
5+
// aux-build:crate-method-reexport-grrrrrrr2.rs
6+
7+
use crate_method_reexport_grrrrrrr2;
8+
9+
fn main() {
10+
import crate_method_reexport_grrrrrrr2::rust::methods;
11+
let x = @();
12+
x.cx();
13+
let y = ();
14+
y.add("hi");
15+
}

0 commit comments

Comments
 (0)