@@ -205,16 +205,17 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
205
205
let def = ecx. tcx . lookup_adt_def ( enum_did) ;
206
206
self . encode_fields ( enum_did) ;
207
207
for ( i, variant) in def. variants . iter ( ) . enumerate ( ) {
208
- self . record ( variant. did , |this| this. encode_enum_variant_info ( enum_did, i, vis) ) ;
208
+ self . record ( variant. did ,
209
+ ItemContentBuilder :: encode_enum_variant_info,
210
+ ( enum_did, i, vis) ) ;
209
211
}
210
212
}
211
213
}
212
214
213
215
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
214
216
fn encode_enum_variant_info ( & mut self ,
215
- enum_did : DefId , // enum def-id
216
- index : usize , // variant index
217
- vis : & hir:: Visibility ) {
217
+ ( enum_did, index, vis) :
218
+ ( DefId , usize , & hir:: Visibility ) ) {
218
219
let ecx = self . ecx ;
219
220
let def = ecx. tcx . lookup_adt_def ( enum_did) ;
220
221
let variant = & def. variants [ index] ;
@@ -293,11 +294,8 @@ fn encode_reexports(ecx: &EncodeContext,
293
294
294
295
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
295
296
fn encode_info_for_mod ( & mut self ,
296
- md : & hir:: Mod ,
297
- attrs : & [ ast:: Attribute ] ,
298
- id : NodeId ,
299
- name : Name ,
300
- vis : & hir:: Visibility ) {
297
+ ( md, attrs, id, name, vis) :
298
+ ( & hir:: Mod , & [ ast:: Attribute ] , NodeId , Name , & hir:: Visibility ) ) {
301
299
let ecx = self . ecx ( ) ;
302
300
303
301
encode_def_id_and_key ( ecx, self . rbml_w , ecx. tcx . map . local_def_id ( id) ) ;
@@ -418,19 +416,18 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
418
416
let def = self . ecx . tcx . lookup_adt_def ( adt_def_id) ;
419
417
for ( variant_index, variant) in def. variants . iter ( ) . enumerate ( ) {
420
418
for ( field_index, field) in variant. fields . iter ( ) . enumerate ( ) {
421
- self . record ( field. did , |this| this . encode_field ( adt_def_id ,
422
- variant_index ,
423
- field_index) ) ;
419
+ self . record ( field. did ,
420
+ ItemContentBuilder :: encode_field ,
421
+ ( adt_def_id , variant_index , field_index) ) ;
424
422
}
425
423
}
426
424
}
427
425
}
428
426
429
427
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
430
428
fn encode_field ( & mut self ,
431
- adt_def_id : DefId ,
432
- variant_index : usize ,
433
- field_index : usize ) {
429
+ ( adt_def_id, variant_index, field_index) :
430
+ ( DefId , usize , usize ) ) {
434
431
let ecx = self . ecx ( ) ;
435
432
let def = ecx. tcx . lookup_adt_def ( adt_def_id) ;
436
433
let variant = & def. variants [ variant_index] ;
@@ -454,9 +451,8 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
454
451
455
452
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
456
453
fn encode_struct_ctor ( & mut self ,
457
- struct_def_id : DefId ,
458
- struct_node_id : ast:: NodeId ,
459
- ctor_node_id : ast:: NodeId ) {
454
+ ( struct_def_id, struct_node_id, ctor_node_id) :
455
+ ( DefId , ast:: NodeId , ast:: NodeId ) ) {
460
456
let ecx = self . ecx ( ) ;
461
457
let def = ecx. tcx . lookup_adt_def ( struct_def_id) ;
462
458
let variant = def. struct_variant ( ) ;
@@ -532,9 +528,8 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
532
528
533
529
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
534
530
fn encode_info_for_trait_item ( & mut self ,
535
- trait_def_id : DefId ,
536
- item_def_id : DefId ,
537
- trait_item : & hir:: TraitItem ) {
531
+ ( trait_def_id, item_def_id, trait_item) :
532
+ ( DefId , DefId , & hir:: TraitItem ) ) {
538
533
let ecx = self . ecx ;
539
534
let tcx = ecx. tcx ;
540
535
@@ -635,9 +630,8 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
635
630
}
636
631
637
632
fn encode_info_for_impl_item ( & mut self ,
638
- impl_id : NodeId ,
639
- impl_item_def_id : DefId ,
640
- ast_item : Option < & hir:: ImplItem > ) {
633
+ ( impl_id, impl_item_def_id, ast_item) :
634
+ ( NodeId , DefId , Option < & hir:: ImplItem > ) ) {
641
635
match self . ecx . tcx . impl_or_trait_item ( impl_item_def_id) {
642
636
ty:: ConstTraitItem ( ref associated_const) => {
643
637
self . encode_info_for_associated_const ( & associated_const,
@@ -882,8 +876,7 @@ fn encode_xrefs<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
882
876
883
877
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
884
878
fn encode_info_for_item ( & mut self ,
885
- def_id : DefId ,
886
- item : & hir:: Item ) {
879
+ ( def_id, item) : ( DefId , & hir:: Item ) ) {
887
880
let ecx = self . ecx ( ) ;
888
881
let tcx = ecx. tcx ;
889
882
@@ -943,11 +936,7 @@ impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> {
943
936
self . encode_method_argument_names ( & decl) ;
944
937
}
945
938
hir:: ItemMod ( ref m) => {
946
- self . encode_info_for_mod ( m,
947
- & item. attrs ,
948
- item. id ,
949
- item. name ,
950
- & item. vis ) ;
939
+ self . encode_info_for_mod ( ( m, & item. attrs , item. id , item. name , & item. vis ) ) ;
951
940
}
952
941
hir:: ItemForeignMod ( ref fm) => {
953
942
encode_def_id_and_key ( ecx, self . rbml_w , def_id) ;
@@ -1210,9 +1199,9 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1210
1199
// there is a value for structs like `struct
1211
1200
// Foo()` and `struct Foo`
1212
1201
let ctor_def_id = ecx. tcx . map . local_def_id ( struct_node_id) ;
1213
- self . record ( ctor_def_id, |this| this . encode_struct_ctor ( def_id ,
1214
- item . id ,
1215
- struct_node_id) ) ;
1202
+ self . record ( ctor_def_id,
1203
+ ItemContentBuilder :: encode_struct_ctor ,
1204
+ ( def_id , item . id , struct_node_id) ) ;
1216
1205
}
1217
1206
}
1218
1207
}
@@ -1238,9 +1227,9 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1238
1227
} ;
1239
1228
1240
1229
let trait_item_def_id = trait_item_def_id. def_id ( ) ;
1241
- self . record ( trait_item_def_id, |this| {
1242
- this . encode_info_for_impl_item ( impl_id , trait_item_def_id , ast_item )
1243
- } ) ;
1230
+ self . record ( trait_item_def_id,
1231
+ ItemContentBuilder :: encode_info_for_impl_item ,
1232
+ ( impl_id , trait_item_def_id , ast_item ) ) ;
1244
1233
}
1245
1234
}
1246
1235
@@ -1253,17 +1242,16 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1253
1242
for ( item_def_id, trait_item) in r. iter ( ) . zip ( trait_items) {
1254
1243
let item_def_id = item_def_id. def_id ( ) ;
1255
1244
assert ! ( item_def_id. is_local( ) ) ;
1256
- self . record ( item_def_id, |this| {
1257
- this . encode_info_for_trait_item ( def_id , item_def_id , trait_item )
1258
- } ) ;
1245
+ self . record ( item_def_id,
1246
+ ItemContentBuilder :: encode_info_for_trait_item ,
1247
+ ( def_id , item_def_id , trait_item ) ) ;
1259
1248
}
1260
1249
}
1261
1250
}
1262
1251
1263
1252
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
1264
1253
fn encode_info_for_foreign_item ( & mut self ,
1265
- def_id : DefId ,
1266
- nitem : & hir:: ForeignItem ) {
1254
+ ( def_id, nitem) : ( DefId , & hir:: ForeignItem ) ) {
1267
1255
let ecx = self . ecx ( ) ;
1268
1256
1269
1257
debug ! ( "writing foreign item {}" , ecx. tcx. node_path_str( nitem. id) ) ;
@@ -1323,14 +1311,18 @@ impl<'a, 'ecx, 'tcx, 'encoder> Visitor<'tcx> for EncodeVisitor<'a, 'ecx, 'tcx, '
1323
1311
let def_id = self . index . ecx . tcx . map . local_def_id ( item. id ) ;
1324
1312
match item. node {
1325
1313
hir:: ItemExternCrate ( _) | hir:: ItemUse ( _) => ( ) , // ignore these
1326
- _ => self . index . record ( def_id, |index| index. encode_info_for_item ( def_id, item) ) ,
1314
+ _ => self . index . record ( def_id,
1315
+ ItemContentBuilder :: encode_info_for_item,
1316
+ ( def_id, item) ) ,
1327
1317
}
1328
1318
self . index . encode_addl_info_for_item ( item) ;
1329
1319
}
1330
1320
fn visit_foreign_item ( & mut self , ni : & ' tcx hir:: ForeignItem ) {
1331
1321
intravisit:: walk_foreign_item ( self , ni) ;
1332
1322
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) ) ;
1323
+ self . index . record ( def_id,
1324
+ ItemContentBuilder :: encode_info_for_foreign_item,
1325
+ ( def_id, ni) ) ;
1334
1326
}
1335
1327
fn visit_ty ( & mut self , ty : & ' tcx hir:: Ty ) {
1336
1328
intravisit:: walk_ty ( self , ty) ;
@@ -1343,11 +1335,9 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1343
1335
let ecx = self . ecx ( ) ;
1344
1336
if let hir:: TyImplTrait ( _) = ty. node {
1345
1337
let def_id = ecx. tcx . map . local_def_id ( ty. id ) ;
1346
- self . record ( def_id, |this| {
1347
- encode_def_id_and_key ( ecx, this. rbml_w , def_id) ;
1348
- encode_family ( this. rbml_w , 'y' ) ;
1349
- this. encode_bounds_and_type_for_item ( ty. id ) ;
1350
- } ) ;
1338
+ self . record ( def_id,
1339
+ ItemContentBuilder :: encode_info_for_anon_ty,
1340
+ ( def_id, ty. id ) ) ;
1351
1341
}
1352
1342
}
1353
1343
@@ -1357,16 +1347,24 @@ impl<'a, 'tcx, 'encoder> IndexBuilder<'a, 'tcx, 'encoder> {
1357
1347
match expr. node {
1358
1348
hir:: ExprClosure ( ..) => {
1359
1349
let def_id = ecx. tcx . map . local_def_id ( expr. id ) ;
1360
-
1361
- self . record ( def_id, |this| this. encode_info_for_closure ( def_id, expr. id ) ) ;
1350
+ self . record ( def_id,
1351
+ ItemContentBuilder :: encode_info_for_closure,
1352
+ ( def_id, expr. id ) ) ;
1362
1353
}
1363
1354
_ => { }
1364
1355
}
1365
1356
}
1366
1357
}
1367
1358
1368
1359
impl < ' a , ' tcx , ' encoder > ItemContentBuilder < ' a , ' tcx , ' encoder > {
1369
- fn encode_info_for_closure ( & mut self , def_id : DefId , expr_id : NodeId ) {
1360
+ fn encode_info_for_anon_ty ( & mut self , ( def_id, ty_id) : ( DefId , NodeId ) ) {
1361
+ let ecx = self . ecx ;
1362
+ encode_def_id_and_key ( ecx, self . rbml_w , def_id) ;
1363
+ encode_family ( self . rbml_w , 'y' ) ;
1364
+ self . encode_bounds_and_type_for_item ( ty_id) ;
1365
+ }
1366
+
1367
+ fn encode_info_for_closure ( & mut self , ( def_id, expr_id) : ( DefId , NodeId ) ) {
1370
1368
let ecx = self . ecx ;
1371
1369
encode_def_id_and_key ( ecx, self . rbml_w , def_id) ;
1372
1370
encode_name ( self . rbml_w , syntax:: parse:: token:: intern ( "<closure>" ) ) ;
@@ -1395,13 +1393,13 @@ fn encode_info_for_items<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
1395
1393
1396
1394
let fields = {
1397
1395
let mut index = IndexBuilder :: new ( ecx, rbml_w) ;
1398
- index. record ( DefId :: local ( CRATE_DEF_INDEX ) , |this| {
1399
- this . encode_info_for_mod ( & krate . module ,
1400
- & [ ] ,
1401
- CRATE_NODE_ID ,
1402
- syntax :: parse :: token :: intern ( & ecx . link_meta . crate_name ) ,
1403
- & hir :: Public ) ;
1404
- } ) ;
1396
+ index. record ( DefId :: local ( CRATE_DEF_INDEX ) ,
1397
+ ItemContentBuilder :: encode_info_for_mod,
1398
+ ( & krate . module ,
1399
+ & [ ] ,
1400
+ CRATE_NODE_ID ,
1401
+ syntax :: parse :: token :: intern ( & ecx . link_meta . crate_name ) ,
1402
+ & hir :: Public ) ) ;
1405
1403
krate. visit_all_items ( & mut EncodeVisitor {
1406
1404
index : & mut index,
1407
1405
} ) ;
0 commit comments