Skip to content

Commit 6a41eb0

Browse files
committed
rustc: Break a dependency between metadata and resolve
1 parent b329e1c commit 6a41eb0

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

src/rustc/metadata/encoder.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type encode_parms = {
4848
diag: span_handler,
4949
tcx: ty::ctxt,
5050
reachable: hashmap<ast::node_id, ()>,
51-
exp_map: resolve::exp_map,
51+
reexports: [(str, def_id)],
5252
impl_map: resolve::impl_map,
5353
item_symbols: hashmap<ast::node_id, str>,
5454
discrim_symbols: hashmap<ast::node_id, str>,
@@ -61,7 +61,7 @@ enum encode_ctxt = {
6161
diag: span_handler,
6262
tcx: ty::ctxt,
6363
reachable: hashmap<ast::node_id, ()>,
64-
exp_map: resolve::exp_map,
64+
reexports: [(str, def_id)],
6565
impl_map: resolve::impl_map,
6666
item_symbols: hashmap<ast::node_id, str>,
6767
discrim_symbols: hashmap<ast::node_id, str>,
@@ -260,19 +260,13 @@ fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
260260

261261
fn encode_reexport_paths(ebml_w: ebml::writer,
262262
ecx: @encode_ctxt, &index: [entry<str>]) {
263-
let tcx = ecx.tcx;
264-
for ecx.exp_map.each {|exp_id, defs|
265-
for defs.each {|def|
266-
if !def.reexp { cont; }
267-
let path = alt check tcx.items.get(exp_id) {
268-
ast_map::node_export(_, path) { ast_map::path_to_str(*path) }
269-
};
270-
index += [{val: path, pos: ebml_w.writer.tell()}];
271-
ebml_w.start_tag(tag_paths_data_item);
272-
encode_name(ebml_w, path);
273-
encode_def_id(ebml_w, def.id);
274-
ebml_w.end_tag();
275-
}
263+
for ecx.reexports.each {|reexport|
264+
let (path, def_id) = reexport;
265+
index += [{val: path, pos: ebml_w.writer.tell()}];
266+
ebml_w.start_tag(tag_paths_data_item);
267+
encode_name(ebml_w, path);
268+
encode_def_id(ebml_w, def_id);
269+
ebml_w.end_tag();
276270
}
277271
}
278272

@@ -1071,7 +1065,7 @@ fn encode_metadata(parms: encode_parms, crate: @crate) -> [u8] {
10711065
diag: parms.diag,
10721066
tcx: parms.tcx,
10731067
reachable: parms.reachable,
1074-
exp_map: parms.exp_map,
1068+
reexports: parms.reexports,
10751069
impl_map: parms.impl_map,
10761070
item_symbols: parms.item_symbols,
10771071
discrim_symbols: parms.discrim_symbols,

src/rustc/middle/trans/base.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5197,17 +5197,33 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
51975197
let encode_inlined_item =
51985198
bind astencode::encode_inlined_item(_, _, _, _, cx.maps);
51995199

5200-
{
5200+
ret {
52015201
diag: cx.sess.diagnostic(),
52025202
tcx: cx.tcx,
52035203
reachable: cx.reachable,
5204-
exp_map: cx.exp_map,
5204+
reexports: reexports(cx),
52055205
impl_map: cx.maps.impl_map,
52065206
item_symbols: cx.item_symbols,
52075207
discrim_symbols: cx.discrim_symbols,
52085208
link_meta: cx.link_meta,
52095209
cstore: cx.sess.cstore,
52105210
encode_inlined_item: encode_inlined_item
5211+
};
5212+
5213+
fn reexports(cx: @crate_ctxt) -> [(str, ast::def_id)] {
5214+
let mut reexports = [];
5215+
for cx.exp_map.each {|exp_id, defs|
5216+
for defs.each {|def|
5217+
if !def.reexp { cont; }
5218+
let path = alt check cx.tcx.items.get(exp_id) {
5219+
ast_map::node_export(_, path) {
5220+
ast_map::path_to_str(*path)
5221+
}
5222+
};
5223+
reexports += [(path, def.id)];
5224+
}
5225+
}
5226+
ret reexports;
52115227
}
52125228

52135229
}

0 commit comments

Comments
 (0)