Skip to content

Commit 81c5791

Browse files
committed
---
yaml --- r: 12842 b: refs/heads/master c: 322b20d h: refs/heads/master v: v3
1 parent 4e86b95 commit 81c5791

File tree

3 files changed

+44
-36
lines changed

3 files changed

+44
-36
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 6a41eb0192cfe1489c4f5720082f09ed4fbe9eda
2+
refs/heads/master: 322b20d14d3f7633800afdac92e3a684b3d828bc
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf

trunk/src/rustc/metadata/encoder.rs

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import util::ppaux::ty_to_str;
44

5-
import std::{ebml, map, list};
5+
import std::{ebml, map};
66
import std::map::hashmap;
77
import io::writer_util;
88
import ebml::writer;
@@ -17,7 +17,6 @@ import middle::ast_map;
1717
import syntax::attr;
1818
import std::serialization::serializer;
1919
import std::ebml::serializer;
20-
import middle::resolve;
2120
import syntax::ast;
2221
import syntax::diagnostic::span_handler;
2322

@@ -49,7 +48,7 @@ type encode_parms = {
4948
tcx: ty::ctxt,
5049
reachable: hashmap<ast::node_id, ()>,
5150
reexports: [(str, def_id)],
52-
impl_map: resolve::impl_map,
51+
impl_map: fn@(ast::node_id) -> [(ident, def_id)],
5352
item_symbols: hashmap<ast::node_id, str>,
5453
discrim_symbols: hashmap<ast::node_id, str>,
5554
link_meta: link_meta,
@@ -62,7 +61,7 @@ enum encode_ctxt = {
6261
tcx: ty::ctxt,
6362
reachable: hashmap<ast::node_id, ()>,
6463
reexports: [(str, def_id)],
65-
impl_map: resolve::impl_map,
64+
impl_map: fn@(ast::node_id) -> [(ident, def_id)],
6665
item_symbols: hashmap<ast::node_id, str>,
6766
discrim_symbols: hashmap<ast::node_id, str>,
6867
link_meta: link_meta,
@@ -405,36 +404,31 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
405404
encode_def_id(ebml_w, local_def(id));
406405
encode_family(ebml_w, 'm');
407406
encode_name(ebml_w, name);
408-
alt ecx.impl_map.get(id) {
409-
list::cons(impls, @list::nil) {
410-
for vec::each(*impls) {|i|
411-
if ast_util::is_exported(i.ident, md) {
412-
ebml_w.start_tag(tag_mod_impl);
407+
let impls = ecx.impl_map(id);
408+
for impls.each {|i|
409+
let (ident, did) = i;
410+
if ast_util::is_exported(ident, md) {
411+
ebml_w.start_tag(tag_mod_impl);
413412
/* If did stands for an iface
414-
ref, we need to map it to its parent class */
415-
alt ecx.tcx.items.get(i.did.node) {
416-
ast_map::node_item(it@@{node: cl@item_class(*),_},_) {
417-
ebml_w.wr_str(def_to_str(local_def(it.id)));
418-
some(ty::lookup_item_type(ecx.tcx, i.did).ty)
419-
}
420-
ast_map::node_item(@{node: item_impl(_,_,
421-
some(ifce),_,_),_},_) {
422-
ebml_w.wr_str(def_to_str(i.did));
423-
some(ty::node_id_to_type(ecx.tcx, ifce.id))
424-
}
425-
_ {
426-
ebml_w.wr_str(def_to_str(i.did)); none
427-
}
428-
};
429-
ebml_w.end_tag();
430-
} // if
431-
} // for
432-
} // list::cons alt
433-
_ {
434-
ecx.diag.handler().bug(#fmt("encode_info_for_mod: empty impl_map \
435-
entry for %?", path));
436-
}
437-
}
413+
ref, we need to map it to its parent class */
414+
alt ecx.tcx.items.get(did.node) {
415+
ast_map::node_item(it@@{node: cl@item_class(*),_},_) {
416+
ebml_w.wr_str(def_to_str(local_def(it.id)));
417+
some(ty::lookup_item_type(ecx.tcx, did).ty)
418+
}
419+
ast_map::node_item(@{node: item_impl(_,_,
420+
some(ifce),_,_),_},_) {
421+
ebml_w.wr_str(def_to_str(did));
422+
some(ty::node_id_to_type(ecx.tcx, ifce.id))
423+
}
424+
_ {
425+
ebml_w.wr_str(def_to_str(did)); none
426+
}
427+
};
428+
ebml_w.end_tag();
429+
} // if
430+
} // for
431+
438432
encode_path(ebml_w, path, ast_map::path_mod(name));
439433
ebml_w.end_tag();
440434
}

trunk/src/rustc/middle/trans/base.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
1515

1616
import libc::c_uint;
17-
import std::{map, time};
17+
import std::{map, time, list};
1818
import std::map::hashmap;
1919
import std::map::{int_hash, str_hash};
2020
import driver::session;
@@ -5202,7 +5202,7 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
52025202
tcx: cx.tcx,
52035203
reachable: cx.reachable,
52045204
reexports: reexports(cx),
5205-
impl_map: cx.maps.impl_map,
5205+
impl_map: impl_map(cx, _),
52065206
item_symbols: cx.item_symbols,
52075207
discrim_symbols: cx.discrim_symbols,
52085208
link_meta: cx.link_meta,
@@ -5226,6 +5226,20 @@ fn crate_ctxt_to_encode_parms(cx: @crate_ctxt)
52265226
ret reexports;
52275227
}
52285228

5229+
fn impl_map(cx: @crate_ctxt,
5230+
id: ast::node_id) -> [(ast::ident, ast::def_id)] {
5231+
alt cx.maps.impl_map.get(id) {
5232+
list::cons(impls, @list::nil) {
5233+
(*impls).map {|i|
5234+
(i.ident, i.did)
5235+
}
5236+
}
5237+
_ {
5238+
cx.sess.bug(#fmt("encode_info_for_mod: empty impl_map \
5239+
entry for %?", id));
5240+
}
5241+
}
5242+
}
52295243
}
52305244

52315245
fn write_metadata(cx: @crate_ctxt, crate: @ast::crate) {

0 commit comments

Comments
 (0)