@@ -413,9 +413,8 @@ fn decode_ast(par_doc: rbml::Doc) -> ast::InlinedItem {
413413// ______________________________________________________________________
414414// Encoding and decoding of ast::def
415415
416- fn decode_def ( dcx : & DecodeContext , doc : rbml:: Doc ) -> def:: Def {
417- let mut dsr = reader:: Decoder :: new ( doc) ;
418- let def: def:: Def = Decodable :: decode ( & mut dsr) . unwrap ( ) ;
416+ fn decode_def ( dcx : & DecodeContext , dsr : & mut reader:: Decoder ) -> def:: Def {
417+ let def: def:: Def = Decodable :: decode ( dsr) . unwrap ( ) ;
419418 def. tr ( dcx)
420419}
421420
@@ -1114,7 +1113,7 @@ impl<'a> write_tag_and_id for Encoder<'a> {
11141113 }
11151114
11161115 fn id ( & mut self , id : ast:: NodeId ) {
1117- self . wr_tagged_u64 ( c :: tag_table_id as uint , id as u64 ) ;
1116+ id . encode ( self ) . unwrap ( ) ;
11181117 }
11191118}
11201119
@@ -1151,51 +1150,44 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
11511150 if let Some ( def) = tcx. def_map . borrow ( ) . get ( & id) . map ( |d| d. full_def ( ) ) {
11521151 rbml_w. tag ( c:: tag_table_def, |rbml_w| {
11531152 rbml_w. id ( id) ;
1154- rbml_w . tag ( c :: tag_table_val , |rbml_w| def. encode ( rbml_w) . unwrap ( ) ) ;
1153+ def. encode ( rbml_w) . unwrap ( ) ;
11551154 } )
11561155 }
11571156
11581157 if let Some ( ty) = tcx. node_types . borrow ( ) . get ( & id) {
11591158 rbml_w. tag ( c:: tag_table_node_type, |rbml_w| {
11601159 rbml_w. id ( id) ;
1161- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1162- rbml_w. emit_ty ( ecx, * ty) ;
1163- } )
1160+ rbml_w. emit_ty ( ecx, * ty) ;
11641161 } )
11651162 }
11661163
11671164 if let Some ( item_substs) = tcx. item_substs . borrow ( ) . get ( & id) {
11681165 rbml_w. tag ( c:: tag_table_item_subst, |rbml_w| {
11691166 rbml_w. id ( id) ;
1170- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1171- rbml_w. emit_substs ( ecx, & item_substs. substs ) ;
1172- } )
1167+ rbml_w. emit_substs ( ecx, & item_substs. substs ) ;
11731168 } )
11741169 }
11751170
11761171 if let Some ( fv) = tcx. freevars . borrow ( ) . get ( & id) {
11771172 rbml_w. tag ( c:: tag_table_freevars, |rbml_w| {
11781173 rbml_w. id ( id) ;
1179- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1180- rbml_w. emit_from_vec ( fv, |rbml_w, fv_entry| {
1181- Ok ( encode_freevar_entry ( rbml_w, fv_entry) )
1182- } ) ;
1183- } )
1174+ rbml_w. emit_from_vec ( fv, |rbml_w, fv_entry| {
1175+ Ok ( encode_freevar_entry ( rbml_w, fv_entry) )
1176+ } ) ;
11841177 } ) ;
11851178
11861179 for freevar in fv {
11871180 rbml_w. tag ( c:: tag_table_upvar_capture_map, |rbml_w| {
11881181 rbml_w. id ( id) ;
1189- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1190- let var_id = freevar. def . def_id ( ) . node ;
1191- let upvar_id = ty:: UpvarId {
1192- var_id : var_id,
1193- closure_expr_id : id
1194- } ;
1195- let upvar_capture = tcx. upvar_capture_map . borrow ( ) [ upvar_id] . clone ( ) ;
1196- var_id. encode ( rbml_w) ;
1197- upvar_capture. encode ( rbml_w) ;
1198- } )
1182+
1183+ let var_id = freevar. def . def_id ( ) . node ;
1184+ let upvar_id = ty:: UpvarId {
1185+ var_id : var_id,
1186+ closure_expr_id : id
1187+ } ;
1188+ let upvar_capture = tcx. upvar_capture_map . borrow ( ) [ upvar_id] . clone ( ) ;
1189+ var_id. encode ( rbml_w) ;
1190+ upvar_capture. encode ( rbml_w) ;
11991191 } )
12001192 }
12011193 }
@@ -1204,37 +1196,29 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12041196 if let Some ( type_scheme) = tcx. tcache . borrow ( ) . get ( & lid) {
12051197 rbml_w. tag ( c:: tag_table_tcache, |rbml_w| {
12061198 rbml_w. id ( id) ;
1207- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1208- rbml_w. emit_type_scheme ( ecx, type_scheme. clone ( ) ) ;
1209- } )
1199+ rbml_w. emit_type_scheme ( ecx, type_scheme. clone ( ) ) ;
12101200 } )
12111201 }
12121202
12131203 if let Some ( type_param_def) = tcx. ty_param_defs . borrow ( ) . get ( & id) {
12141204 rbml_w. tag ( c:: tag_table_param_defs, |rbml_w| {
12151205 rbml_w. id ( id) ;
1216- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1217- rbml_w. emit_type_param_def ( ecx, type_param_def)
1218- } )
1206+ rbml_w. emit_type_param_def ( ecx, type_param_def)
12191207 } )
12201208 }
12211209
12221210 let method_call = MethodCall :: expr ( id) ;
12231211 if let Some ( method) = tcx. method_map . borrow ( ) . get ( & method_call) {
12241212 rbml_w. tag ( c:: tag_table_method_map, |rbml_w| {
12251213 rbml_w. id ( id) ;
1226- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1227- encode_method_callee ( ecx, rbml_w, method_call. adjustment , method)
1228- } )
1214+ encode_method_callee ( ecx, rbml_w, method_call. adjustment , method)
12291215 } )
12301216 }
12311217
12321218 if let Some ( trait_ref) = tcx. object_cast_map . borrow ( ) . get ( & id) {
12331219 rbml_w. tag ( c:: tag_table_object_cast_map, |rbml_w| {
12341220 rbml_w. id ( id) ;
1235- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1236- rbml_w. emit_trait_ref ( ecx, & * trait_ref. 0 ) ;
1237- } )
1221+ rbml_w. emit_trait_ref ( ecx, & * trait_ref. 0 ) ;
12381222 } )
12391223 }
12401224
@@ -1245,9 +1229,7 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12451229 if let Some ( method) = tcx. method_map . borrow ( ) . get ( & method_call) {
12461230 rbml_w. tag ( c:: tag_table_method_map, |rbml_w| {
12471231 rbml_w. id ( id) ;
1248- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1249- encode_method_callee ( ecx, rbml_w, method_call. adjustment , method)
1250- } )
1232+ encode_method_callee ( ecx, rbml_w, method_call. adjustment , method)
12511233 } )
12521234 }
12531235 }
@@ -1258,10 +1240,8 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12581240 if let Some ( method) = tcx. method_map . borrow ( ) . get ( & method_call) {
12591241 rbml_w. tag ( c:: tag_table_method_map, |rbml_w| {
12601242 rbml_w. id ( id) ;
1261- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1262- encode_method_callee ( ecx, rbml_w,
1263- method_call. adjustment , method)
1264- } )
1243+ encode_method_callee ( ecx, rbml_w,
1244+ method_call. adjustment , method)
12651245 } )
12661246 }
12671247 }
@@ -1273,36 +1253,28 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
12731253
12741254 rbml_w. tag ( c:: tag_table_adjustments, |rbml_w| {
12751255 rbml_w. id ( id) ;
1276- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1277- rbml_w. emit_auto_adjustment ( ecx, adjustment) ;
1278- } )
1256+ rbml_w. emit_auto_adjustment ( ecx, adjustment) ;
12791257 } )
12801258 }
12811259
12821260 if let Some ( closure_type) = tcx. closure_tys . borrow ( ) . get ( & ast_util:: local_def ( id) ) {
12831261 rbml_w. tag ( c:: tag_table_closure_tys, |rbml_w| {
12841262 rbml_w. id ( id) ;
1285- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1286- rbml_w. emit_closure_type ( ecx, closure_type) ;
1287- } )
1263+ rbml_w. emit_closure_type ( ecx, closure_type) ;
12881264 } )
12891265 }
12901266
12911267 if let Some ( closure_kind) = tcx. closure_kinds . borrow ( ) . get ( & ast_util:: local_def ( id) ) {
12921268 rbml_w. tag ( c:: tag_table_closure_kinds, |rbml_w| {
12931269 rbml_w. id ( id) ;
1294- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1295- encode_closure_kind ( rbml_w, * closure_kind)
1296- } )
1270+ encode_closure_kind ( rbml_w, * closure_kind)
12971271 } )
12981272 }
12991273
13001274 for & qualif in tcx. const_qualif_map . borrow ( ) . get ( & id) . iter ( ) {
13011275 rbml_w. tag ( c:: tag_table_const_qualif, |rbml_w| {
13021276 rbml_w. id ( id) ;
1303- rbml_w. tag ( c:: tag_table_val, |rbml_w| {
1304- qualif. encode ( rbml_w) . unwrap ( )
1305- } )
1277+ qualif. encode ( rbml_w) . unwrap ( )
13061278 } )
13071279 }
13081280}
@@ -1830,8 +1802,9 @@ fn decode_side_tables(dcx: &DecodeContext,
18301802 ast_doc : rbml:: Doc ) {
18311803 let tbl_doc = ast_doc. get ( c:: tag_table as uint ) ;
18321804 reader:: docs ( tbl_doc, |tag, entry_doc| {
1833- let id0 = entry_doc. get ( c:: tag_table_id as uint ) . as_int ( ) ;
1834- let id = dcx. tr_id ( id0 as ast:: NodeId ) ;
1805+ let mut entry_dsr = reader:: Decoder :: new ( entry_doc) ;
1806+ let id0: ast:: NodeId = Decodable :: decode ( & mut entry_dsr) . unwrap ( ) ;
1807+ let id = dcx. tr_id ( id0) ;
18351808
18361809 debug ! ( ">> Side table document with tag 0x{:x} \
18371810 found for id {} (orig {})",
@@ -1844,13 +1817,11 @@ fn decode_side_tables(dcx: &DecodeContext,
18441817 tag) ) ;
18451818 }
18461819 Some ( value) => {
1847- let val_doc = entry_doc. get ( c:: tag_table_val as uint ) ;
1848- let mut val_dsr = reader:: Decoder :: new ( val_doc) ;
1849- let val_dsr = & mut val_dsr;
1820+ let val_dsr = & mut entry_dsr;
18501821
18511822 match value {
18521823 c:: tag_table_def => {
1853- let def = decode_def ( dcx, val_doc ) ;
1824+ let def = decode_def ( dcx, val_dsr ) ;
18541825 dcx. tcx . def_map . borrow_mut ( ) . insert ( id, def:: PathResolution {
18551826 base_def : def,
18561827 // This doesn't matter cross-crate.
0 commit comments