rustc: Make all impls even more reachable
With this we write metadata for all impls so that we can properly find reexported impls.
This commit is contained in:
parent
200a2ded32
commit
46fba10fe8
3 changed files with 49 additions and 14 deletions
|
@ -27,7 +27,7 @@ fn find_reachable(crate_mod: _mod, exp_map: resolve::exp_map,
|
||||||
let rmap = std::map::int_hash();
|
let rmap = std::map::int_hash();
|
||||||
let cx = {exp_map: exp_map, tcx: tcx, method_map: method_map, rmap: rmap};
|
let cx = {exp_map: exp_map, tcx: tcx, method_map: method_map, rmap: rmap};
|
||||||
traverse_public_mod(cx, crate_mod);
|
traverse_public_mod(cx, crate_mod);
|
||||||
traverse_all_resources(cx, crate_mod);
|
traverse_all_resources_and_impls(cx, crate_mod);
|
||||||
rmap
|
rmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,18 +81,6 @@ fn traverse_public_mod(cx: ctx, m: _mod) {
|
||||||
if !traverse_exports(cx, m.view_items) {
|
if !traverse_exports(cx, m.view_items) {
|
||||||
// No exports, so every local item is exported
|
// No exports, so every local item is exported
|
||||||
for vec::each(m.items) |item| { traverse_public_item(cx, item); }
|
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::visit_mod(crate_mod, ast_util::dummy_sp(), 0, cx, visit::mk_vt(@{
|
||||||
visit_expr: |_e, _cx, _v| { },
|
visit_expr: |_e, _cx, _v| { },
|
||||||
visit_item: |i, cx, v| {
|
visit_item: |i, cx, v| {
|
||||||
|
@ -221,9 +209,13 @@ fn traverse_all_resources(cx: ctx, crate_mod: _mod) {
|
||||||
item_class(_, _, _, _, some(_)) {
|
item_class(_, _, _, _, some(_)) {
|
||||||
traverse_public_item(cx, i);
|
traverse_public_item(cx, i);
|
||||||
}
|
}
|
||||||
|
item_impl(*) {
|
||||||
|
traverse_public_item(cx, i);
|
||||||
|
}
|
||||||
_ {}
|
_ {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with *visit::default_visitor()
|
with *visit::default_visitor()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
28
src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs
Normal file
28
src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs
Normal file
|
@ -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() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
src/test/run-pass/crate-method-reexport-grrrrrrr.rs
Normal file
15
src/test/run-pass/crate-method-reexport-grrrrrrr.rs
Normal file
|
@ -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");
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue