Skip to content

Commit 94c0617

Browse files
committed
rustc: Resolve external modules and native modules to definition IDs as well
1 parent 77f8546 commit 94c0617

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

src/comp/front/creader.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ impure fn move_to_item(&ebml.reader ebml_r, int item_id) {
360360
}
361361

362362
log #fmt("move_to_item: item not found: %d", item_id);
363+
fail;
363364
}
364365

365366
// Looks up an item in the given metadata and returns an EBML reader pointing
@@ -559,11 +560,13 @@ fn lookup_def(session.session sess, &span sp, int cnum, vec[ast.ident] path)
559560
did = tup(cnum, did._1);
560561

561562
// FIXME: It'd be great if we had u8 char literals.
562-
if (kind_ch == ('c' as u8)) { ret ast.def_const(did); }
563-
else if (kind_ch == ('f' as u8)) { ret ast.def_fn(did); }
564-
else if (kind_ch == ('y' as u8)) { ret ast.def_ty(did); }
565-
else if (kind_ch == ('o' as u8)) { ret ast.def_obj(did); }
566-
else if (kind_ch == ('t' as u8)) { ret ast.def_ty(did); }
563+
if (kind_ch == ('c' as u8)) { ret ast.def_const(did); }
564+
else if (kind_ch == ('f' as u8)) { ret ast.def_fn(did); }
565+
else if (kind_ch == ('y' as u8)) { ret ast.def_ty(did); }
566+
else if (kind_ch == ('o' as u8)) { ret ast.def_obj(did); }
567+
else if (kind_ch == ('t' as u8)) { ret ast.def_ty(did); }
568+
else if (kind_ch == ('m' as u8)) { ret ast.def_mod(did); }
569+
else if (kind_ch == ('n' as u8)) { ret ast.def_native_mod(did); }
567570
else if (kind_ch == ('v' as u8)) {
568571
auto tid = get_variant_tag_id(ebml_r);
569572
tid = tup(cnum, tid._1);

src/comp/middle/metadata.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,17 @@ fn encode_module_item_paths(&ebml.writer ebml_w, &ast._mod module) {
210210
encode_def_id(ebml_w, did);
211211
ebml.end_tag(ebml_w);
212212
}
213-
case (ast.item_mod(?id, ?_mod, _)) {
213+
case (ast.item_mod(?id, ?_mod, ?did)) {
214214
ebml.start_tag(ebml_w, tag_paths_mod);
215215
encode_name(ebml_w, id);
216+
encode_def_id(ebml_w, did);
216217
encode_module_item_paths(ebml_w, _mod);
217218
ebml.end_tag(ebml_w);
218219
}
219-
case (ast.item_native_mod(?id, ?nmod, _)) {
220+
case (ast.item_native_mod(?id, ?nmod, ?did)) {
220221
ebml.start_tag(ebml_w, tag_paths_mod);
221222
encode_name(ebml_w, id);
223+
encode_def_id(ebml_w, did);
222224
encode_native_module_item_paths(ebml_w, nmod);
223225
ebml.end_tag(ebml_w);
224226
}
@@ -336,11 +338,17 @@ fn encode_info_for_item(@trans.crate_ctxt cx, &ebml.writer ebml_w,
336338
encode_symbol(cx, ebml_w, did);
337339
ebml.end_tag(ebml_w);
338340
}
339-
case (ast.item_mod(_, _, _)) {
340-
// nothing to do
341+
case (ast.item_mod(_, _, ?did)) {
342+
ebml.start_tag(ebml_w, tag_items_item);
343+
encode_def_id(ebml_w, did);
344+
encode_kind(ebml_w, 'm' as u8);
345+
ebml.end_tag(ebml_w);
341346
}
342-
case (ast.item_native_mod(_, _, _)) {
343-
// nothing to do
347+
case (ast.item_native_mod(_, _, ?did)) {
348+
ebml.start_tag(ebml_w, tag_items_item);
349+
encode_def_id(ebml_w, did);
350+
encode_kind(ebml_w, 'n' as u8);
351+
ebml.end_tag(ebml_w);
344352
}
345353
case (ast.item_ty(?id, _, ?tps, ?did, ?ann)) {
346354
ebml.start_tag(ebml_w, tag_items_item);

0 commit comments

Comments
 (0)