Skip to content

Commit e5a5fc2

Browse files
committed
Allow impls to be re-exported
It was a little hard for me to believe, but it seems that re-exporting an impl doesn't work at a, because encoder::encode_info_for_mod requires that all the impls in the current module's impl map be local (that is, bound to a value in the current crate's item map). Fixed it. Closes rust-lang#2414.
1 parent 1db8515 commit e5a5fc2

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

src/rustc/metadata/encoder.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -396,17 +396,21 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
396396
let (ident, did) = i;
397397
if ast_util::is_exported(ident, md) {
398398
ebml_w.start_tag(tag_mod_impl);
399+
alt ecx.tcx.items.find(did.node) {
400+
some(ast_map::node_item(it@@{node: cl@item_class(*),_},_)) {
399401
/* If did stands for an iface
400402
ref, we need to map it to its parent class */
401-
alt ecx.tcx.items.get(did.node) {
402-
ast_map::node_item(it@@{node: cl@item_class(*),_},_) {
403403
ebml_w.wr_str(def_to_str(local_def(it.id)));
404404
}
405-
ast_map::node_item(@{node: item_impl(_,_,
406-
some(ifce),_,_),_},_) {
405+
some(ast_map::node_item(@{node: item_impl(_,_,
406+
some(ifce),_,_),_},_)) {
407407
ebml_w.wr_str(def_to_str(did));
408408
}
409-
_ {
409+
some(_) {
410+
ebml_w.wr_str(def_to_str(did));
411+
}
412+
none {
413+
// Must be a re-export, then!
410414
ebml_w.wr_str(def_to_str(did));
411415
}
412416
};

src/test/auxiliary/issue-2414-a.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#[link(name = "a", vers = "0.1")];
2+
#[crate_type = "lib"];
3+
4+
type t1 = uint;
5+
impl t2 for str { }

src/test/auxiliary/issue-2414-b.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// xfail-fast
2+
3+
#[link(name = "b", vers = "0.1")];
4+
#[crate_type = "lib"];
5+
6+
use a;
7+
8+
import a::t2;
9+
export t2;

src/test/run-pass/issue-2414-c.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// xfail-fast
2+
// aux-build:issue-2414-a.rs
3+
// aux-build:issue-2414-b.rs
4+
5+
use b;
6+
7+
fn main() {}

0 commit comments

Comments
 (0)