@@ -1258,54 +1258,54 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1258
1258
} ) ;
1259
1259
}
1260
1260
}
1261
+ }
1261
1262
1263
+ impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
1262
1264
fn encode_info_for_foreign_item ( & mut self ,
1265
+ def_id : DefId ,
1263
1266
nitem : & hir:: ForeignItem ) {
1264
1267
let ecx = self . ecx ( ) ;
1265
1268
1266
1269
debug ! ( "writing foreign item {}" , ecx. tcx. node_path_str( nitem. id) ) ;
1267
- let def_id = ecx. tcx . map . local_def_id ( nitem. id ) ;
1268
1270
let abi = ecx. tcx . map . get_foreign_abi ( nitem. id ) ;
1269
1271
1270
- self . record ( def_id, |this| {
1271
- encode_def_id_and_key ( ecx, this. rbml_w , def_id) ;
1272
- let parent_id = ecx. tcx . map . get_parent ( nitem. id ) ;
1273
- this. encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
1274
- this. encode_visibility ( & nitem. vis ) ;
1275
- match nitem. node {
1276
- hir:: ForeignItemFn ( ref fndecl, _) => {
1277
- encode_family ( this. rbml_w , FN_FAMILY ) ;
1278
- this. encode_bounds_and_type_for_item ( nitem. id ) ;
1279
- encode_name ( this. rbml_w , nitem. name ) ;
1280
- if abi == Abi :: RustIntrinsic || abi == Abi :: PlatformIntrinsic {
1281
- encode_inlined_item ( ecx,
1282
- this. rbml_w ,
1283
- InlinedItemRef :: Foreign ( def_id, nitem) ) ;
1284
- this. encode_mir ( nitem. id ) ;
1285
- }
1286
- encode_attributes ( this. rbml_w , & nitem. attrs ) ;
1287
- let stab = ecx. tcx . lookup_stability ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1288
- let depr = ecx. tcx . lookup_deprecation ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1289
- encode_stability ( this. rbml_w , stab) ;
1290
- encode_deprecation ( this. rbml_w , depr) ;
1291
- this. encode_method_argument_names ( & fndecl) ;
1272
+ encode_def_id_and_key ( ecx, self . rbml_w , def_id) ;
1273
+ let parent_id = ecx. tcx . map . get_parent ( nitem. id ) ;
1274
+ self . encode_parent_item ( ecx. tcx . map . local_def_id ( parent_id) ) ;
1275
+ self . encode_visibility ( & nitem. vis ) ;
1276
+ match nitem. node {
1277
+ hir:: ForeignItemFn ( ref fndecl, _) => {
1278
+ encode_family ( self . rbml_w , FN_FAMILY ) ;
1279
+ self . encode_bounds_and_type_for_item ( nitem. id ) ;
1280
+ encode_name ( self . rbml_w , nitem. name ) ;
1281
+ if abi == Abi :: RustIntrinsic || abi == Abi :: PlatformIntrinsic {
1282
+ encode_inlined_item ( ecx,
1283
+ self . rbml_w ,
1284
+ InlinedItemRef :: Foreign ( def_id, nitem) ) ;
1285
+ self . encode_mir ( nitem. id ) ;
1292
1286
}
1293
- hir:: ForeignItemStatic ( _, mutbl) => {
1294
- if mutbl {
1295
- encode_family ( this. rbml_w , 'b' ) ;
1296
- } else {
1297
- encode_family ( this. rbml_w , 'c' ) ;
1298
- }
1299
- this. encode_bounds_and_type_for_item ( nitem. id ) ;
1300
- encode_attributes ( this. rbml_w , & nitem. attrs ) ;
1301
- let stab = ecx. tcx . lookup_stability ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1302
- let depr = ecx. tcx . lookup_deprecation ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1303
- encode_stability ( this. rbml_w , stab) ;
1304
- encode_deprecation ( this. rbml_w , depr) ;
1305
- encode_name ( this. rbml_w , nitem. name ) ;
1287
+ encode_attributes ( self . rbml_w , & nitem. attrs ) ;
1288
+ let stab = ecx. tcx . lookup_stability ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1289
+ let depr = ecx. tcx . lookup_deprecation ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1290
+ encode_stability ( self . rbml_w , stab) ;
1291
+ encode_deprecation ( self . rbml_w , depr) ;
1292
+ self . encode_method_argument_names ( & fndecl) ;
1293
+ }
1294
+ hir:: ForeignItemStatic ( _, mutbl) => {
1295
+ if mutbl {
1296
+ encode_family ( self . rbml_w , 'b' ) ;
1297
+ } else {
1298
+ encode_family ( self . rbml_w , 'c' ) ;
1306
1299
}
1300
+ self . encode_bounds_and_type_for_item ( nitem. id ) ;
1301
+ encode_attributes ( self . rbml_w , & nitem. attrs ) ;
1302
+ let stab = ecx. tcx . lookup_stability ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1303
+ let depr = ecx. tcx . lookup_deprecation ( ecx. tcx . map . local_def_id ( nitem. id ) ) ;
1304
+ encode_stability ( self . rbml_w , stab) ;
1305
+ encode_deprecation ( self . rbml_w , depr) ;
1306
+ encode_name ( self . rbml_w , nitem. name ) ;
1307
1307
}
1308
- } ) ;
1308
+ }
1309
1309
}
1310
1310
}
1311
1311
@@ -1329,7 +1329,8 @@ impl<'a, 'ecx, 'tcx, 'encoder> Visitor<'tcx> for EncodeVisitor<'a, 'ecx, 'tcx, '
1329
1329
}
1330
1330
fn visit_foreign_item ( & mut self , ni : & ' tcx hir:: ForeignItem ) {
1331
1331
intravisit:: walk_foreign_item ( self , ni) ;
1332
- self . index . encode_info_for_foreign_item ( ni) ;
1332
+ let def_id = self . index . ecx . tcx . map . local_def_id ( ni. id ) ;
1333
+ self . index . record ( def_id, |index| index. encode_info_for_foreign_item ( def_id, ni) ) ;
1333
1334
}
1334
1335
fn visit_ty ( & mut self , ty : & ' tcx hir:: Ty ) {
1335
1336
intravisit:: walk_ty ( self , ty) ;
@@ -1357,29 +1358,34 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1357
1358
hir:: ExprClosure ( ..) => {
1358
1359
let def_id = ecx. tcx . map . local_def_id ( expr. id ) ;
1359
1360
1360
- self . record ( def_id, |this| {
1361
- encode_def_id_and_key ( ecx, this. rbml_w , def_id) ;
1362
- encode_name ( this. rbml_w , syntax:: parse:: token:: intern ( "<closure>" ) ) ;
1363
-
1364
- this. rbml_w . start_tag ( tag_items_closure_ty) ;
1365
- write_closure_type ( ecx,
1366
- this. rbml_w ,
1367
- & ecx. tcx . tables . borrow ( ) . closure_tys [ & def_id] ) ;
1368
- this. rbml_w . end_tag ( ) ;
1369
-
1370
- this. rbml_w . start_tag ( tag_items_closure_kind) ;
1371
- ecx. tcx . closure_kind ( def_id) . encode ( this. rbml_w ) . unwrap ( ) ;
1372
- this. rbml_w . end_tag ( ) ;
1373
-
1374
- assert ! ( ecx. mir_map. map. contains_key( & def_id) ) ;
1375
- this. encode_mir ( expr. id ) ;
1376
- } ) ;
1361
+ self . record ( def_id, |this| this. encode_info_for_closure ( def_id, expr. id ) ) ;
1377
1362
}
1378
1363
_ => { }
1379
1364
}
1380
1365
}
1381
1366
}
1382
1367
1368
+ impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
1369
+ fn encode_info_for_closure ( & mut self , def_id : DefId , expr_id : NodeId ) {
1370
+ let ecx = self . ecx ;
1371
+ encode_def_id_and_key ( ecx, self . rbml_w , def_id) ;
1372
+ encode_name ( self . rbml_w , syntax:: parse:: token:: intern ( "<closure>" ) ) ;
1373
+
1374
+ self . rbml_w . start_tag ( tag_items_closure_ty) ;
1375
+ write_closure_type ( ecx,
1376
+ self . rbml_w ,
1377
+ & ecx. tcx . tables . borrow ( ) . closure_tys [ & def_id] ) ;
1378
+ self . rbml_w . end_tag ( ) ;
1379
+
1380
+ self . rbml_w . start_tag ( tag_items_closure_kind) ;
1381
+ ecx. tcx . closure_kind ( def_id) . encode ( self . rbml_w ) . unwrap ( ) ;
1382
+ self . rbml_w . end_tag ( ) ;
1383
+
1384
+ assert ! ( ecx. mir_map. map. contains_key( & def_id) ) ;
1385
+ self . encode_mir ( expr_id) ;
1386
+ }
1387
+ }
1388
+
1383
1389
fn encode_info_for_items < ' a , ' tcx > ( ecx : & EncodeContext < ' a , ' tcx > ,
1384
1390
rbml_w : & mut Encoder )
1385
1391
-> ( IndexData , FnvHashMap < XRef < ' tcx > , u32 > ) {
0 commit comments