@@ -91,8 +91,8 @@ fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Name) {
9191 rbml_w. wr_tagged_str ( tag_item_impl_type_basename, & token:: get_name ( name) ) ;
9292}
9393
94- pub fn encode_def_id ( rbml_w : & mut Encoder , id : DefId ) {
95- rbml_w. wr_tagged_str ( tag_def_id, & def_to_string ( id) ) ;
94+ fn encode_def_id ( rbml_w : & mut Encoder , id : DefId ) {
95+ rbml_w. wr_tagged_u64 ( tag_def_id, def_to_u64 ( id) ) ;
9696}
9797
9898#[ derive( Clone ) ]
@@ -122,6 +122,10 @@ fn encode_family(rbml_w: &mut Encoder, c: char) {
122122 rbml_w. wr_tagged_u8 ( tag_items_data_item_family, c as u8 ) ;
123123}
124124
125+ pub fn def_to_u64 ( did : DefId ) -> u64 {
126+ ( did. krate as u64 ) << 32 | ( did. node as u64 )
127+ }
128+
125129pub fn def_to_string ( did : DefId ) -> String {
126130 format ! ( "{}:{}" , did. krate, did. node)
127131}
@@ -153,9 +157,9 @@ fn encode_bounds_and_type<'a, 'tcx>(rbml_w: &mut Encoder,
153157}
154158
155159fn encode_variant_id ( rbml_w : & mut Encoder , vid : DefId ) {
156- let s = def_to_string ( vid) ;
157- rbml_w. wr_tagged_str ( tag_items_data_item_variant, & s [ .. ] ) ;
158- rbml_w. wr_tagged_str ( tag_mod_child, & s [ .. ] ) ;
160+ let id = def_to_u64 ( vid) ;
161+ rbml_w. wr_tagged_u64 ( tag_items_data_item_variant, id ) ;
162+ rbml_w. wr_tagged_u64 ( tag_mod_child, id ) ;
159163}
160164
161165pub fn write_closure_type < ' a , ' tcx > ( ecx : & EncodeContext < ' a , ' tcx > ,
@@ -260,7 +264,7 @@ fn encode_disr_val(_: &EncodeContext,
260264}
261265
262266fn encode_parent_item ( rbml_w : & mut Encoder , id : DefId ) {
263- rbml_w. wr_tagged_str ( tag_items_data_parent_item, & def_to_string ( id) ) ;
267+ rbml_w. wr_tagged_u64 ( tag_items_data_parent_item, def_to_u64 ( id) ) ;
264268}
265269
266270fn encode_struct_fields ( rbml_w : & mut Encoder ,
@@ -275,7 +279,7 @@ fn encode_struct_fields(rbml_w: &mut Encoder,
275279 }
276280 encode_struct_field_family ( rbml_w, f. vis ) ;
277281 encode_def_id ( rbml_w, f. id ) ;
278- rbml_w. wr_tagged_str ( tag_item_field_origin, & def_to_string ( origin) ) ;
282+ rbml_w. wr_tagged_u64 ( tag_item_field_origin, def_to_u64 ( origin) ) ;
279283 rbml_w. end_tag ( ) ;
280284 }
281285}
@@ -358,8 +362,8 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,
358362 debug ! ( "(encode reexported static method) {}::{}" ,
359363 exp. name, token:: get_name( method_name) ) ;
360364 rbml_w. start_tag ( tag_items_data_item_reexport) ;
361- rbml_w. wr_tagged_str ( tag_items_data_item_reexport_def_id,
362- & def_to_string ( method_def_id) ) ;
365+ rbml_w. wr_tagged_u64 ( tag_items_data_item_reexport_def_id,
366+ def_to_u64 ( method_def_id) ) ;
363367 rbml_w. wr_tagged_str ( tag_items_data_item_reexport_name,
364368 & format ! ( "{}::{}" , exp. name,
365369 token:: get_name( method_name) ) ) ;
@@ -495,8 +499,8 @@ fn encode_reexports(ecx: &EncodeContext,
495499 exp. def_id. node,
496500 id) ;
497501 rbml_w. start_tag ( tag_items_data_item_reexport) ;
498- rbml_w. wr_tagged_str ( tag_items_data_item_reexport_def_id,
499- & def_to_string ( exp. def_id ) ) ;
502+ rbml_w. wr_tagged_u64 ( tag_items_data_item_reexport_def_id,
503+ def_to_u64 ( exp. def_id ) ) ;
500504 rbml_w. wr_tagged_str ( tag_items_data_item_reexport_name,
501505 exp. name . as_str ( ) ) ;
502506 rbml_w. end_tag ( ) ;
@@ -526,12 +530,12 @@ fn encode_info_for_mod(ecx: &EncodeContext,
526530
527531 // Encode info about all the module children.
528532 for item in & md. items {
529- rbml_w. wr_tagged_str ( tag_mod_child,
530- & def_to_string ( local_def ( item. id ) ) ) ;
533+ rbml_w. wr_tagged_u64 ( tag_mod_child,
534+ def_to_u64 ( local_def ( item. id ) ) ) ;
531535
532536 each_auxiliary_node_id ( & * * item, |auxiliary_node_id| {
533- rbml_w. wr_tagged_str ( tag_mod_child,
534- & def_to_string ( local_def ( auxiliary_node_id) ) ) ;
537+ rbml_w. wr_tagged_u64 ( tag_mod_child,
538+ def_to_u64 ( local_def ( auxiliary_node_id) ) ) ;
535539 true
536540 } ) ;
537541
@@ -541,8 +545,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
541545 token:: get_ident( ident) ,
542546 did, ecx. tcx. map. node_to_string( did) ) ;
543547
544- rbml_w. wr_tagged_str ( tag_mod_impl,
545- & def_to_string ( local_def ( did) ) ) ;
548+ rbml_w. wr_tagged_u64 ( tag_mod_impl, def_to_u64 ( local_def ( did) ) ) ;
546549 }
547550 }
548551
@@ -619,8 +622,7 @@ fn encode_parent_sort(rbml_w: &mut Encoder, sort: char) {
619622fn encode_provided_source ( rbml_w : & mut Encoder ,
620623 source_opt : Option < DefId > ) {
621624 if let Some ( source) = source_opt {
622- rbml_w. wr_tagged_str ( tag_item_method_provided_source,
623- & def_to_string ( source) ) ;
625+ rbml_w. wr_tagged_u64 ( tag_item_method_provided_source, def_to_u64 ( source) ) ;
624626 }
625627}
626628
@@ -725,8 +727,8 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
725727 encode_name ( rbml_w, param. name ) ;
726728 rbml_w. end_tag ( ) ;
727729
728- rbml_w. wr_tagged_str ( tag_region_param_def_def_id,
729- & def_to_string ( param. def_id ) ) ;
730+ rbml_w. wr_tagged_u64 ( tag_region_param_def_def_id,
731+ def_to_u64 ( param. def_id ) ) ;
730732
731733 rbml_w. wr_tagged_u64 ( tag_region_param_def_space,
732734 param. space . to_uint ( ) as u64 ) ;
@@ -1089,8 +1091,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
10891091
10901092 // Encode all the items in this module.
10911093 for foreign_item in & fm. items {
1092- rbml_w. wr_tagged_str ( tag_mod_child,
1093- & def_to_string ( local_def ( foreign_item. id ) ) ) ;
1094+ rbml_w. wr_tagged_u64 ( tag_mod_child,
1095+ def_to_u64 ( local_def ( foreign_item. id ) ) ) ;
10941096 }
10951097 encode_visibility ( rbml_w, vis) ;
10961098 encode_stability ( rbml_w, stab) ;
@@ -1335,8 +1337,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
13351337 }
13361338 rbml_w. end_tag ( ) ;
13371339
1338- rbml_w. wr_tagged_str ( tag_mod_child,
1339- & def_to_string ( method_def_id. def_id ( ) ) ) ;
1340+ rbml_w. wr_tagged_u64 ( tag_mod_child,
1341+ def_to_u64 ( method_def_id. def_id ( ) ) ) ;
13401342 }
13411343 encode_path ( rbml_w, path. clone ( ) ) ;
13421344
@@ -1893,6 +1895,7 @@ impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'b, 'c, 'tcx> {
18931895 def_id. krate != ast:: LOCAL_CRATE {
18941896 self . rbml_w . start_tag ( tag_impls_impl) ;
18951897 encode_def_id ( self . rbml_w , local_def ( item. id ) ) ;
1898+ self . rbml_w . wr_tagged_u64 ( tag_impls_impl_trait_def_id, def_to_u64 ( def_id) ) ;
18961899 self . rbml_w . end_tag ( ) ;
18971900 }
18981901 }
@@ -1932,12 +1935,12 @@ fn encode_misc_info(ecx: &EncodeContext,
19321935 rbml_w. start_tag ( tag_misc_info) ;
19331936 rbml_w. start_tag ( tag_misc_info_crate_items) ;
19341937 for item in & krate. module . items {
1935- rbml_w. wr_tagged_str ( tag_mod_child,
1936- & def_to_string ( local_def ( item. id ) ) ) ;
1938+ rbml_w. wr_tagged_u64 ( tag_mod_child,
1939+ def_to_u64 ( local_def ( item. id ) ) ) ;
19371940
19381941 each_auxiliary_node_id ( & * * item, |auxiliary_node_id| {
1939- rbml_w. wr_tagged_str ( tag_mod_child,
1940- & def_to_string ( local_def ( auxiliary_node_id) ) ) ;
1942+ rbml_w. wr_tagged_u64 ( tag_mod_child,
1943+ def_to_u64 ( local_def ( auxiliary_node_id) ) ) ;
19411944 true
19421945 } ) ;
19431946 }
0 commit comments