|
1 |
| -// Metadata decoding |
| 1 | +// Decoding metadata from a single crate's metadata |
2 | 2 |
|
3 | 3 | import std::ebml;
|
4 | 4 | import std::ivec;
|
@@ -85,14 +85,21 @@ fn variant_tag_id(&ebml::doc d) -> ast::def_id {
|
85 | 85 | fn item_type(&ebml::doc item, ast::crate_num this_cnum,
|
86 | 86 | ty::ctxt tcx) -> ty::t {
|
87 | 87 | 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 |
| - |
93 | 88 | auto buf = str::bytes(s);
|
94 | 89 | 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 | + } |
96 | 103 | }
|
97 | 104 | auto tp = ebml::get_doc(item, tag_items_data_item_type);
|
98 | 105 | ret parse_ty_data(item.data, this_cnum, tp.start, tp.end - tp.start,
|
|
0 commit comments