@@ -91,8 +91,8 @@ fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Name) {
91
91
rbml_w. wr_tagged_str ( tag_item_impl_type_basename, & token:: get_name ( name) ) ;
92
92
}
93
93
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) ) ;
96
96
}
97
97
98
98
#[ derive( Clone ) ]
@@ -122,6 +122,10 @@ fn encode_family(rbml_w: &mut Encoder, c: char) {
122
122
rbml_w. wr_tagged_u8 ( tag_items_data_item_family, c as u8 ) ;
123
123
}
124
124
125
+ pub fn def_to_u64 ( did : DefId ) -> u64 {
126
+ ( did. krate as u64 ) << 32 | ( did. node as u64 )
127
+ }
128
+
125
129
pub fn def_to_string ( did : DefId ) -> String {
126
130
format ! ( "{}:{}" , did. krate, did. node)
127
131
}
@@ -153,9 +157,9 @@ fn encode_bounds_and_type<'a, 'tcx>(rbml_w: &mut Encoder,
153
157
}
154
158
155
159
fn 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 ) ;
159
163
}
160
164
161
165
pub fn write_closure_type < ' a , ' tcx > ( ecx : & EncodeContext < ' a , ' tcx > ,
@@ -260,7 +264,7 @@ fn encode_disr_val(_: &EncodeContext,
260
264
}
261
265
262
266
fn 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) ) ;
264
268
}
265
269
266
270
fn encode_struct_fields ( rbml_w : & mut Encoder ,
@@ -275,7 +279,7 @@ fn encode_struct_fields(rbml_w: &mut Encoder,
275
279
}
276
280
encode_struct_field_family ( rbml_w, f. vis ) ;
277
281
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) ) ;
279
283
rbml_w. end_tag ( ) ;
280
284
}
281
285
}
@@ -358,8 +362,8 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,
358
362
debug ! ( "(encode reexported static method) {}::{}" ,
359
363
exp. name, token:: get_name( method_name) ) ;
360
364
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) ) ;
363
367
rbml_w. wr_tagged_str ( tag_items_data_item_reexport_name,
364
368
& format ! ( "{}::{}" , exp. name,
365
369
token:: get_name( method_name) ) ) ;
@@ -495,8 +499,8 @@ fn encode_reexports(ecx: &EncodeContext,
495
499
exp. def_id. node,
496
500
id) ;
497
501
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 ) ) ;
500
504
rbml_w. wr_tagged_str ( tag_items_data_item_reexport_name,
501
505
exp. name . as_str ( ) ) ;
502
506
rbml_w. end_tag ( ) ;
@@ -526,12 +530,12 @@ fn encode_info_for_mod(ecx: &EncodeContext,
526
530
527
531
// Encode info about all the module children.
528
532
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 ) ) ) ;
531
535
532
536
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) ) ) ;
535
539
true
536
540
} ) ;
537
541
@@ -541,8 +545,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
541
545
token:: get_ident( ident) ,
542
546
did, ecx. tcx. map. node_to_string( did) ) ;
543
547
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) ) ) ;
546
549
}
547
550
}
548
551
@@ -619,8 +622,7 @@ fn encode_parent_sort(rbml_w: &mut Encoder, sort: char) {
619
622
fn encode_provided_source ( rbml_w : & mut Encoder ,
620
623
source_opt : Option < DefId > ) {
621
624
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) ) ;
624
626
}
625
627
}
626
628
@@ -725,8 +727,8 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
725
727
encode_name ( rbml_w, param. name ) ;
726
728
rbml_w. end_tag ( ) ;
727
729
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 ) ) ;
730
732
731
733
rbml_w. wr_tagged_u64 ( tag_region_param_def_space,
732
734
param. space . to_uint ( ) as u64 ) ;
@@ -1089,8 +1091,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
1089
1091
1090
1092
// Encode all the items in this module.
1091
1093
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 ) ) ) ;
1094
1096
}
1095
1097
encode_visibility ( rbml_w, vis) ;
1096
1098
encode_stability ( rbml_w, stab) ;
@@ -1335,8 +1337,8 @@ fn encode_info_for_item(ecx: &EncodeContext,
1335
1337
}
1336
1338
rbml_w. end_tag ( ) ;
1337
1339
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 ( ) ) ) ;
1340
1342
}
1341
1343
encode_path ( rbml_w, path. clone ( ) ) ;
1342
1344
@@ -1893,6 +1895,7 @@ impl<'a, 'b, 'c, 'tcx, 'v> Visitor<'v> for ImplVisitor<'a, 'b, 'c, 'tcx> {
1893
1895
def_id. krate != ast:: LOCAL_CRATE {
1894
1896
self . rbml_w . start_tag ( tag_impls_impl) ;
1895
1897
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) ) ;
1896
1899
self . rbml_w . end_tag ( ) ;
1897
1900
}
1898
1901
}
@@ -1932,12 +1935,12 @@ fn encode_misc_info(ecx: &EncodeContext,
1932
1935
rbml_w. start_tag ( tag_misc_info) ;
1933
1936
rbml_w. start_tag ( tag_misc_info_crate_items) ;
1934
1937
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 ) ) ) ;
1937
1940
1938
1941
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) ) ) ;
1941
1944
true
1942
1945
} ) ;
1943
1946
}
0 commit comments