2
2
3
3
import util:: ppaux:: ty_to_str;
4
4
5
- import std:: { ebml, map, list } ;
5
+ import std:: { ebml, map} ;
6
6
import std:: map:: hashmap;
7
7
import io:: writer_util;
8
8
import ebml:: writer;
@@ -17,7 +17,6 @@ import middle::ast_map;
17
17
import syntax:: attr;
18
18
import std:: serialization:: serializer;
19
19
import std:: ebml:: serializer;
20
- import middle:: resolve;
21
20
import syntax:: ast;
22
21
import syntax:: diagnostic:: span_handler;
23
22
@@ -49,7 +48,7 @@ type encode_parms = {
49
48
tcx : ty:: ctxt ,
50
49
reachable : hashmap < ast:: node_id , ( ) > ,
51
50
reexports : [ ( str , def_id ) ] ,
52
- impl_map : resolve :: impl_map ,
51
+ impl_map : fn @ ( ast :: node_id ) -> [ ( ident , def_id ) ] ,
53
52
item_symbols : hashmap < ast:: node_id , str > ,
54
53
discrim_symbols : hashmap < ast:: node_id , str > ,
55
54
link_meta : link_meta ,
@@ -62,7 +61,7 @@ enum encode_ctxt = {
62
61
tcx: ty:: ctxt,
63
62
reachable: hashmap<ast:: node_id, ( ) >,
64
63
reexports: [ ( str, def_id) ] ,
65
- impl_map: resolve :: impl_map ,
64
+ impl_map: fn @ ( ast :: node_id ) -> [ ( ident , def_id ) ] ,
66
65
item_symbols: hashmap<ast:: node_id, str>,
67
66
discrim_symbols: hashmap<ast:: node_id, str>,
68
67
link_meta: link_meta,
@@ -405,36 +404,31 @@ fn encode_info_for_mod(ecx: @encode_ctxt, ebml_w: ebml::writer, md: _mod,
405
404
encode_def_id( ebml_w, local_def( id) ) ;
406
405
encode_family( ebml_w, 'm' ) ;
407
406
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) ;
413
412
/* 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
+
438
432
encode_path( ebml_w, path, ast_map:: path_mod( name) ) ;
439
433
ebml_w. end_tag( ) ;
440
434
}
0 commit comments