Skip to content

Commit 00d5401

Browse files
committed
Cleanup decoding and crate searching
1 parent 06391dd commit 00d5401

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/comp/metadata/csearch.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Searching for information from the cstore
2+
13
import syntax::ast;
24
import middle::ty;
35
import std::io;

src/comp/metadata/decoder.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Metadata decoding
1+
// Decoding metadata from a single crate's metadata
22

33
import std::ebml;
44
import std::ivec;
@@ -85,14 +85,21 @@ fn variant_tag_id(&ebml::doc d) -> ast::def_id {
8585
fn item_type(&ebml::doc item, ast::crate_num this_cnum,
8686
ty::ctxt tcx) -> ty::t {
8787
fn parse_external_def_id(ast::crate_num this_cnum, str s) -> ast::def_id {
88-
// FIXME: This is completely wrong when linking against a crate
89-
// that, in turn, links against another crate. We need a mapping
90-
// from crate ID to crate "meta" attributes as part of the crate
91-
// metadata:
92-
9388
auto buf = str::bytes(s);
9489
auto external_def_id = parse_def_id(buf);
95-
ret tup(this_cnum, external_def_id._1);
90+
91+
// This item was defined in the crate we're searching if it's has the
92+
// local crate number, otherwise we need to search a different crate
93+
if (external_def_id._0 == ast::local_crate) {
94+
ret tup(this_cnum, external_def_id._1);
95+
} else {
96+
// FIXME: This is completely wrong when linking against a crate
97+
// that, in turn, links against another crate. We need a mapping
98+
// from crate ID to crate "meta" attributes as part of the crate
99+
// metadata:
100+
fail "trying to load type info from a crate that is \
101+
defined in a different crate";
102+
}
96103
}
97104
auto tp = ebml::get_doc(item, tag_items_data_item_type);
98105
ret parse_ty_data(item.data, this_cnum, tp.start, tp.end - tp.start,

0 commit comments

Comments
 (0)