@@ -378,7 +378,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
378
378
// We've been here already, no need to search again.
379
379
return ;
380
380
}
381
- debug ! ( "BEGIN collect_items_rec({})" , starting_point. to_string( ccx) ) ;
381
+ debug ! ( "BEGIN collect_items_rec({})" , starting_point. to_string( ccx. tcx ( ) ) ) ;
382
382
383
383
let mut neighbors = Vec :: new ( ) ;
384
384
let recursion_depth_reset;
@@ -427,7 +427,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
427
427
recursion_depths. insert ( def_id, depth) ;
428
428
}
429
429
430
- debug ! ( "END collect_items_rec({})" , starting_point. to_string( ccx) ) ;
430
+ debug ! ( "END collect_items_rec({})" , starting_point. to_string( ccx. tcx ( ) ) ) ;
431
431
}
432
432
433
433
fn record_references < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
@@ -654,7 +654,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
654
654
}
655
655
} ;
656
656
657
- debug ! ( "find_drop_glue_neighbors: {}" , type_to_string( ccx, ty) ) ;
657
+ debug ! ( "find_drop_glue_neighbors: {}" , type_to_string( ccx. tcx ( ) , ty) ) ;
658
658
659
659
// Make sure the exchange_free_fn() lang-item gets translated if
660
660
// there is a boxed value.
@@ -783,7 +783,7 @@ fn do_static_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
783
783
param_substs : & ' tcx Substs < ' tcx > )
784
784
-> Option < ( DefId , & ' tcx Substs < ' tcx > ) > {
785
785
debug ! ( "do_static_dispatch(fn_def_id={}, fn_substs={:?}, param_substs={:?})" ,
786
- def_id_to_string( ccx, fn_def_id) ,
786
+ def_id_to_string( ccx. tcx ( ) , fn_def_id) ,
787
787
fn_substs,
788
788
param_substs) ;
789
789
@@ -831,8 +831,8 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
831
831
trait_id={}, \
832
832
callee_substs={:?}, \
833
833
param_substs={:?}",
834
- def_id_to_string( ccx, trait_method. def_id) ,
835
- def_id_to_string( ccx, trait_id) ,
834
+ def_id_to_string( ccx. tcx ( ) , trait_method. def_id) ,
835
+ def_id_to_string( ccx. tcx ( ) , trait_id) ,
836
836
callee_substs,
837
837
param_substs) ;
838
838
@@ -965,7 +965,7 @@ fn create_fn_trans_item<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
965
965
-> TransItem < ' tcx >
966
966
{
967
967
debug ! ( "create_fn_trans_item(def_id={}, fn_substs={:?}, param_substs={:?})" ,
968
- def_id_to_string( ccx, def_id) ,
968
+ def_id_to_string( ccx. tcx ( ) , def_id) ,
969
969
fn_substs,
970
970
param_substs) ;
971
971
@@ -1076,7 +1076,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1076
1076
1077
1077
if self . mode == TransItemCollectionMode :: Eager {
1078
1078
debug ! ( "RootCollector: ADT drop-glue for {}" ,
1079
- def_id_to_string( self . ccx,
1079
+ def_id_to_string( self . ccx. tcx ( ) ,
1080
1080
self . ccx. tcx( ) . map. local_def_id( item. id) ) ) ;
1081
1081
1082
1082
let ty = glue:: get_drop_glue_type ( self . ccx , ty) ;
@@ -1086,7 +1086,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1086
1086
}
1087
1087
hir:: ItemStatic ( ..) => {
1088
1088
debug ! ( "RootCollector: ItemStatic({})" ,
1089
- def_id_to_string( self . ccx,
1089
+ def_id_to_string( self . ccx. tcx ( ) ,
1090
1090
self . ccx. tcx( ) . map. local_def_id( item. id) ) ) ;
1091
1091
self . output . push ( TransItem :: Static ( item. id ) ) ;
1092
1092
}
@@ -1096,7 +1096,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1096
1096
let def_id = self . ccx . tcx ( ) . map . local_def_id ( item. id ) ;
1097
1097
1098
1098
debug ! ( "RootCollector: ItemFn({})" ,
1099
- def_id_to_string( self . ccx, def_id) ) ;
1099
+ def_id_to_string( self . ccx. tcx ( ) , def_id) ) ;
1100
1100
1101
1101
let instance = Instance :: mono ( self . ccx . tcx ( ) , def_id) ;
1102
1102
self . output . push ( TransItem :: Fn ( instance) ) ;
@@ -1133,7 +1133,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1133
1133
let def_id = self . ccx . tcx ( ) . map . local_def_id ( ii. id ) ;
1134
1134
1135
1135
debug ! ( "RootCollector: MethodImplItem({})" ,
1136
- def_id_to_string( self . ccx, def_id) ) ;
1136
+ def_id_to_string( self . ccx. tcx ( ) , def_id) ) ;
1137
1137
1138
1138
let instance = Instance :: mono ( self . ccx . tcx ( ) , def_id) ;
1139
1139
self . output . push ( TransItem :: Fn ( instance) ) ;
@@ -1164,7 +1164,7 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1164
1164
let impl_def_id = tcx. map . local_def_id ( item. id ) ;
1165
1165
1166
1166
debug ! ( "create_trans_items_for_default_impls(item={})" ,
1167
- def_id_to_string( ccx, impl_def_id) ) ;
1167
+ def_id_to_string( ccx. tcx ( ) , impl_def_id) ) ;
1168
1168
1169
1169
if let Some ( trait_ref) = tcx. impl_trait_ref ( impl_def_id) {
1170
1170
let default_impls = tcx. provided_trait_methods ( trait_ref. def_id ) ;
@@ -1226,9 +1226,9 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1226
1226
1227
1227
/// Same as `unique_type_name()` but with the result pushed onto the given
1228
1228
/// `output` parameter.
1229
- pub fn push_unique_type_name < ' a , ' tcx > ( cx : & CrateContext < ' a , ' tcx > ,
1230
- t : ty:: Ty < ' tcx > ,
1231
- output : & mut String ) {
1229
+ pub fn push_unique_type_name < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1230
+ t : ty:: Ty < ' tcx > ,
1231
+ output : & mut String ) {
1232
1232
match t. sty {
1233
1233
ty:: TyBool => output. push_str ( "bool" ) ,
1234
1234
ty:: TyChar => output. push_str ( "char" ) ,
@@ -1247,13 +1247,13 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1247
1247
ty:: TyFloat ( ast:: FloatTy :: F64 ) => output. push_str ( "f64" ) ,
1248
1248
ty:: TyStruct ( adt_def, substs) |
1249
1249
ty:: TyEnum ( adt_def, substs) => {
1250
- push_item_name ( cx , adt_def. did , output) ;
1251
- push_type_params ( cx , & substs. types , & [ ] , output) ;
1250
+ push_item_name ( tcx , adt_def. did , output) ;
1251
+ push_type_params ( tcx , & substs. types , & [ ] , output) ;
1252
1252
} ,
1253
1253
ty:: TyTuple ( ref component_types) => {
1254
1254
output. push ( '(' ) ;
1255
1255
for & component_type in component_types {
1256
- push_unique_type_name ( cx , component_type, output) ;
1256
+ push_unique_type_name ( tcx , component_type, output) ;
1257
1257
output. push_str ( ", " ) ;
1258
1258
}
1259
1259
if !component_types. is_empty ( ) {
@@ -1264,7 +1264,7 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1264
1264
} ,
1265
1265
ty:: TyBox ( inner_type) => {
1266
1266
output. push_str ( "Box<" ) ;
1267
- push_unique_type_name ( cx , inner_type, output) ;
1267
+ push_unique_type_name ( tcx , inner_type, output) ;
1268
1268
output. push ( '>' ) ;
1269
1269
} ,
1270
1270
ty:: TyRawPtr ( ty:: TypeAndMut { ty : inner_type, mutbl } ) => {
@@ -1274,30 +1274,30 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1274
1274
hir:: MutMutable => output. push_str ( "mut " ) ,
1275
1275
}
1276
1276
1277
- push_unique_type_name ( cx , inner_type, output) ;
1277
+ push_unique_type_name ( tcx , inner_type, output) ;
1278
1278
} ,
1279
1279
ty:: TyRef ( _, ty:: TypeAndMut { ty : inner_type, mutbl } ) => {
1280
1280
output. push ( '&' ) ;
1281
1281
if mutbl == hir:: MutMutable {
1282
1282
output. push_str ( "mut " ) ;
1283
1283
}
1284
1284
1285
- push_unique_type_name ( cx , inner_type, output) ;
1285
+ push_unique_type_name ( tcx , inner_type, output) ;
1286
1286
} ,
1287
1287
ty:: TyArray ( inner_type, len) => {
1288
1288
output. push ( '[' ) ;
1289
- push_unique_type_name ( cx , inner_type, output) ;
1289
+ push_unique_type_name ( tcx , inner_type, output) ;
1290
1290
output. push_str ( & format ! ( "; {}" , len) ) ;
1291
1291
output. push ( ']' ) ;
1292
1292
} ,
1293
1293
ty:: TySlice ( inner_type) => {
1294
1294
output. push ( '[' ) ;
1295
- push_unique_type_name ( cx , inner_type, output) ;
1295
+ push_unique_type_name ( tcx , inner_type, output) ;
1296
1296
output. push ( ']' ) ;
1297
1297
} ,
1298
1298
ty:: TyTrait ( ref trait_data) => {
1299
- push_item_name ( cx , trait_data. principal . skip_binder ( ) . def_id , output) ;
1300
- push_type_params ( cx ,
1299
+ push_item_name ( tcx , trait_data. principal . skip_binder ( ) . def_id , output) ;
1300
+ push_type_params ( tcx ,
1301
1301
& trait_data. principal . skip_binder ( ) . substs . types ,
1302
1302
& trait_data. bounds . projection_bounds ,
1303
1303
output) ;
@@ -1316,10 +1316,10 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1316
1316
1317
1317
output. push_str ( "fn(" ) ;
1318
1318
1319
- let sig = cx . tcx ( ) . erase_late_bound_regions ( sig) ;
1319
+ let sig = tcx. erase_late_bound_regions ( sig) ;
1320
1320
if !sig. inputs . is_empty ( ) {
1321
1321
for & parameter_type in & sig. inputs {
1322
- push_unique_type_name ( cx , parameter_type, output) ;
1322
+ push_unique_type_name ( tcx , parameter_type, output) ;
1323
1323
output. push_str ( ", " ) ;
1324
1324
}
1325
1325
output. pop ( ) ;
@@ -1340,19 +1340,19 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1340
1340
ty:: FnConverging ( result_type) if result_type. is_nil ( ) => { }
1341
1341
ty:: FnConverging ( result_type) => {
1342
1342
output. push_str ( " -> " ) ;
1343
- push_unique_type_name ( cx , result_type, output) ;
1343
+ push_unique_type_name ( tcx , result_type, output) ;
1344
1344
}
1345
1345
ty:: FnDiverging => {
1346
1346
output. push_str ( " -> !" ) ;
1347
1347
}
1348
1348
}
1349
1349
} ,
1350
1350
ty:: TyClosure ( def_id, ref closure_substs) => {
1351
- push_item_name ( cx , def_id, output) ;
1351
+ push_item_name ( tcx , def_id, output) ;
1352
1352
output. push_str ( "{" ) ;
1353
1353
output. push_str ( & format ! ( "{}:{}" , def_id. krate, def_id. index. as_usize( ) ) ) ;
1354
1354
output. push_str ( "}" ) ;
1355
- push_type_params ( cx , & closure_substs. func_substs . types , & [ ] , output) ;
1355
+ push_type_params ( tcx , & closure_substs. func_substs . types , & [ ] , output) ;
1356
1356
}
1357
1357
ty:: TyError |
1358
1358
ty:: TyInfer ( _) |
@@ -1364,17 +1364,17 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1364
1364
}
1365
1365
}
1366
1366
1367
- fn push_item_name ( ccx : & CrateContext ,
1367
+ fn push_item_name ( tcx : & TyCtxt ,
1368
1368
def_id : DefId ,
1369
1369
output : & mut String ) {
1370
- let def_path = ccx . tcx ( ) . def_path ( def_id) ;
1370
+ let def_path = tcx. def_path ( def_id) ;
1371
1371
1372
1372
// some_crate::
1373
- output. push_str ( & ccx . tcx ( ) . crate_name ( def_path. krate ) ) ;
1373
+ output. push_str ( & tcx. crate_name ( def_path. krate ) ) ;
1374
1374
output. push_str ( "::" ) ;
1375
1375
1376
1376
// foo::bar::ItemName::
1377
- for part in ccx . tcx ( ) . def_path ( def_id) . data {
1377
+ for part in tcx. def_path ( def_id) . data {
1378
1378
output. push_str ( & format ! ( "{}[{}]::" ,
1379
1379
part. data. as_interned_str( ) ,
1380
1380
part. disambiguator) ) ;
@@ -1385,18 +1385,18 @@ fn push_item_name(ccx: &CrateContext,
1385
1385
output. pop ( ) ;
1386
1386
}
1387
1387
1388
- fn push_type_params < ' a , ' tcx > ( cx : & CrateContext < ' a , ' tcx > ,
1389
- types : & ' tcx subst:: VecPerParamSpace < Ty < ' tcx > > ,
1390
- projections : & [ ty:: PolyProjectionPredicate < ' tcx > ] ,
1391
- output : & mut String ) {
1388
+ fn push_type_params < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1389
+ types : & ' tcx subst:: VecPerParamSpace < Ty < ' tcx > > ,
1390
+ projections : & [ ty:: PolyProjectionPredicate < ' tcx > ] ,
1391
+ output : & mut String ) {
1392
1392
if types. is_empty ( ) && projections. is_empty ( ) {
1393
1393
return ;
1394
1394
}
1395
1395
1396
1396
output. push ( '<' ) ;
1397
1397
1398
1398
for & type_parameter in types {
1399
- push_unique_type_name ( cx , type_parameter, output) ;
1399
+ push_unique_type_name ( tcx , type_parameter, output) ;
1400
1400
output. push_str ( ", " ) ;
1401
1401
}
1402
1402
@@ -1405,7 +1405,7 @@ fn push_type_params<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1405
1405
let name = token:: get_ident_interner ( ) . get ( projection. projection_ty . item_name ) ;
1406
1406
output. push_str ( & name[ ..] ) ;
1407
1407
output. push_str ( "=" ) ;
1408
- push_unique_type_name ( cx , projection. ty , output) ;
1408
+ push_unique_type_name ( tcx , projection. ty , output) ;
1409
1409
output. push_str ( ", " ) ;
1410
1410
}
1411
1411
@@ -1415,24 +1415,24 @@ fn push_type_params<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1415
1415
output. push ( '>' ) ;
1416
1416
}
1417
1417
1418
- fn push_instance_as_string < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1419
- instance : Instance < ' tcx > ,
1420
- output : & mut String ) {
1421
- push_item_name ( ccx , instance. def , output) ;
1422
- push_type_params ( ccx , & instance. substs . types , & [ ] , output) ;
1418
+ fn push_instance_as_string < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1419
+ instance : Instance < ' tcx > ,
1420
+ output : & mut String ) {
1421
+ push_item_name ( tcx , instance. def , output) ;
1422
+ push_type_params ( tcx , & instance. substs . types , & [ ] , output) ;
1423
1423
}
1424
1424
1425
- pub fn def_id_to_string ( ccx : & CrateContext , def_id : DefId ) -> String {
1425
+ pub fn def_id_to_string ( tcx : & TyCtxt , def_id : DefId ) -> String {
1426
1426
let mut output = String :: new ( ) ;
1427
- push_item_name ( ccx , def_id, & mut output) ;
1427
+ push_item_name ( tcx , def_id, & mut output) ;
1428
1428
output
1429
1429
}
1430
1430
1431
- fn type_to_string < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1432
- ty : ty:: Ty < ' tcx > )
1433
- -> String {
1431
+ fn type_to_string < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1432
+ ty : ty:: Ty < ' tcx > )
1433
+ -> String {
1434
1434
let mut output = String :: new ( ) ;
1435
- push_unique_type_name ( ccx , ty, & mut output) ;
1435
+ push_unique_type_name ( tcx , ty, & mut output) ;
1436
1436
output
1437
1437
}
1438
1438
@@ -1489,8 +1489,8 @@ impl<'tcx> TransItem<'tcx> {
1489
1489
}
1490
1490
}
1491
1491
1492
- pub fn to_string < ' a > ( & self , ccx : & CrateContext < ' a , ' tcx > ) -> String {
1493
- let hir_map = & ccx . tcx ( ) . map ;
1492
+ pub fn to_string ( & self , tcx : & TyCtxt < ' tcx > ) -> String {
1493
+ let hir_map = & tcx. map ;
1494
1494
1495
1495
return match * self {
1496
1496
TransItem :: DropGlue ( dg) => {
@@ -1499,26 +1499,26 @@ impl<'tcx> TransItem<'tcx> {
1499
1499
DropGlueKind :: Ty ( _) => s. push_str ( "drop-glue " ) ,
1500
1500
DropGlueKind :: TyContents ( _) => s. push_str ( "drop-glue-contents " ) ,
1501
1501
} ;
1502
- push_unique_type_name ( ccx , dg. ty ( ) , & mut s) ;
1502
+ push_unique_type_name ( tcx , dg. ty ( ) , & mut s) ;
1503
1503
s
1504
1504
}
1505
1505
TransItem :: Fn ( instance) => {
1506
- to_string_internal ( ccx , "fn " , instance)
1506
+ to_string_internal ( tcx , "fn " , instance)
1507
1507
} ,
1508
1508
TransItem :: Static ( node_id) => {
1509
1509
let def_id = hir_map. local_def_id ( node_id) ;
1510
- let instance = Instance :: mono ( ccx . tcx ( ) , def_id) ;
1511
- to_string_internal ( ccx , "static " , instance)
1510
+ let instance = Instance :: mono ( tcx, def_id) ;
1511
+ to_string_internal ( tcx , "static " , instance)
1512
1512
} ,
1513
1513
} ;
1514
1514
1515
- fn to_string_internal < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1516
- prefix : & str ,
1517
- instance : Instance < ' tcx > )
1518
- -> String {
1515
+ fn to_string_internal < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1516
+ prefix : & str ,
1517
+ instance : Instance < ' tcx > )
1518
+ -> String {
1519
1519
let mut result = String :: with_capacity ( 32 ) ;
1520
1520
result. push_str ( prefix) ;
1521
- push_instance_as_string ( ccx , instance, & mut result) ;
1521
+ push_instance_as_string ( tcx , instance, & mut result) ;
1522
1522
result
1523
1523
}
1524
1524
}
@@ -1572,7 +1572,7 @@ pub fn print_collection_results<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
1572
1572
let mut item_keys = FnvHashMap ( ) ;
1573
1573
1574
1574
for ( item, item_state) in trans_items. iter ( ) {
1575
- let k = item. to_string ( & ccx) ;
1575
+ let k = item. to_string ( ccx. tcx ( ) ) ;
1576
1576
1577
1577
if item_keys. contains_key ( & k) {
1578
1578
let prev: ( TransItem , TransItemState ) = item_keys[ & k] ;
@@ -1600,7 +1600,7 @@ pub fn print_collection_results<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
1600
1600
let mut generated = FnvHashSet ( ) ;
1601
1601
1602
1602
for ( item, item_state) in trans_items. iter ( ) {
1603
- let item_key = item. to_string ( & ccx) ;
1603
+ let item_key = item. to_string ( ccx. tcx ( ) ) ;
1604
1604
1605
1605
match * item_state {
1606
1606
TransItemState :: PredictedAndGenerated => {
0 commit comments