@@ -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;
@@ -430,7 +430,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(ccx: &CrateContext<'a, 'tcx>,
430
430
recursion_depths. insert ( def_id, depth) ;
431
431
}
432
432
433
- debug ! ( "END collect_items_rec({})" , starting_point. to_string( ccx) ) ;
433
+ debug ! ( "END collect_items_rec({})" , starting_point. to_string( ccx. tcx ( ) ) ) ;
434
434
}
435
435
436
436
fn record_references < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
@@ -657,7 +657,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
657
657
}
658
658
} ;
659
659
660
- debug ! ( "find_drop_glue_neighbors: {}" , type_to_string( ccx, ty) ) ;
660
+ debug ! ( "find_drop_glue_neighbors: {}" , type_to_string( ccx. tcx ( ) , ty) ) ;
661
661
662
662
// Make sure the exchange_free_fn() lang-item gets translated if
663
663
// there is a boxed value.
@@ -786,7 +786,7 @@ fn do_static_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
786
786
param_substs : & ' tcx Substs < ' tcx > )
787
787
-> Option < ( DefId , & ' tcx Substs < ' tcx > ) > {
788
788
debug ! ( "do_static_dispatch(fn_def_id={}, fn_substs={:?}, param_substs={:?})" ,
789
- def_id_to_string( ccx, fn_def_id) ,
789
+ def_id_to_string( ccx. tcx ( ) , fn_def_id) ,
790
790
fn_substs,
791
791
param_substs) ;
792
792
@@ -834,8 +834,8 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
834
834
trait_id={}, \
835
835
callee_substs={:?}, \
836
836
param_substs={:?}",
837
- def_id_to_string( ccx, trait_method. def_id) ,
838
- def_id_to_string( ccx, trait_id) ,
837
+ def_id_to_string( ccx. tcx ( ) , trait_method. def_id) ,
838
+ def_id_to_string( ccx. tcx ( ) , trait_id) ,
839
839
callee_substs,
840
840
param_substs) ;
841
841
@@ -968,7 +968,7 @@ fn create_fn_trans_item<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
968
968
-> TransItem < ' tcx >
969
969
{
970
970
debug ! ( "create_fn_trans_item(def_id={}, fn_substs={:?}, param_substs={:?})" ,
971
- def_id_to_string( ccx, def_id) ,
971
+ def_id_to_string( ccx. tcx ( ) , def_id) ,
972
972
fn_substs,
973
973
param_substs) ;
974
974
@@ -1079,7 +1079,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1079
1079
1080
1080
if self . mode == TransItemCollectionMode :: Eager {
1081
1081
debug ! ( "RootCollector: ADT drop-glue for {}" ,
1082
- def_id_to_string( self . ccx,
1082
+ def_id_to_string( self . ccx. tcx ( ) ,
1083
1083
self . ccx. tcx( ) . map. local_def_id( item. id) ) ) ;
1084
1084
1085
1085
let ty = glue:: get_drop_glue_type ( self . ccx , ty) ;
@@ -1089,7 +1089,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1089
1089
}
1090
1090
hir:: ItemStatic ( ..) => {
1091
1091
debug ! ( "RootCollector: ItemStatic({})" ,
1092
- def_id_to_string( self . ccx,
1092
+ def_id_to_string( self . ccx. tcx ( ) ,
1093
1093
self . ccx. tcx( ) . map. local_def_id( item. id) ) ) ;
1094
1094
self . output . push ( TransItem :: Static ( item. id ) ) ;
1095
1095
}
@@ -1099,7 +1099,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1099
1099
let def_id = self . ccx . tcx ( ) . map . local_def_id ( item. id ) ;
1100
1100
1101
1101
debug ! ( "RootCollector: ItemFn({})" ,
1102
- def_id_to_string( self . ccx, def_id) ) ;
1102
+ def_id_to_string( self . ccx. tcx ( ) , def_id) ) ;
1103
1103
1104
1104
let instance = Instance :: mono ( self . ccx . tcx ( ) , def_id) ;
1105
1105
self . output . push ( TransItem :: Fn ( instance) ) ;
@@ -1136,7 +1136,7 @@ impl<'b, 'a, 'v> hir_visit::Visitor<'v> for RootCollector<'b, 'a, 'v> {
1136
1136
let def_id = self . ccx . tcx ( ) . map . local_def_id ( ii. id ) ;
1137
1137
1138
1138
debug ! ( "RootCollector: MethodImplItem({})" ,
1139
- def_id_to_string( self . ccx, def_id) ) ;
1139
+ def_id_to_string( self . ccx. tcx ( ) , def_id) ) ;
1140
1140
1141
1141
let instance = Instance :: mono ( self . ccx . tcx ( ) , def_id) ;
1142
1142
self . output . push ( TransItem :: Fn ( instance) ) ;
@@ -1167,7 +1167,7 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1167
1167
let impl_def_id = tcx. map . local_def_id ( item. id ) ;
1168
1168
1169
1169
debug ! ( "create_trans_items_for_default_impls(item={})" ,
1170
- def_id_to_string( ccx, impl_def_id) ) ;
1170
+ def_id_to_string( ccx. tcx ( ) , impl_def_id) ) ;
1171
1171
1172
1172
if let Some ( trait_ref) = tcx. impl_trait_ref ( impl_def_id) {
1173
1173
let default_impls = tcx. provided_trait_methods ( trait_ref. def_id ) ;
@@ -1229,9 +1229,9 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
1229
1229
1230
1230
/// Same as `unique_type_name()` but with the result pushed onto the given
1231
1231
/// `output` parameter.
1232
- pub fn push_unique_type_name < ' a , ' tcx > ( cx : & CrateContext < ' a , ' tcx > ,
1233
- t : ty:: Ty < ' tcx > ,
1234
- output : & mut String ) {
1232
+ pub fn push_unique_type_name < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1233
+ t : ty:: Ty < ' tcx > ,
1234
+ output : & mut String ) {
1235
1235
match t. sty {
1236
1236
ty:: TyBool => output. push_str ( "bool" ) ,
1237
1237
ty:: TyChar => output. push_str ( "char" ) ,
@@ -1250,13 +1250,13 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1250
1250
ty:: TyFloat ( ast:: FloatTy :: F64 ) => output. push_str ( "f64" ) ,
1251
1251
ty:: TyStruct ( adt_def, substs) |
1252
1252
ty:: TyEnum ( adt_def, substs) => {
1253
- push_item_name ( cx , adt_def. did , output) ;
1254
- push_type_params ( cx , & substs. types , & [ ] , output) ;
1253
+ push_item_name ( tcx , adt_def. did , output) ;
1254
+ push_type_params ( tcx , & substs. types , & [ ] , output) ;
1255
1255
} ,
1256
1256
ty:: TyTuple ( ref component_types) => {
1257
1257
output. push ( '(' ) ;
1258
1258
for & component_type in component_types {
1259
- push_unique_type_name ( cx , component_type, output) ;
1259
+ push_unique_type_name ( tcx , component_type, output) ;
1260
1260
output. push_str ( ", " ) ;
1261
1261
}
1262
1262
if !component_types. is_empty ( ) {
@@ -1267,7 +1267,7 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1267
1267
} ,
1268
1268
ty:: TyBox ( inner_type) => {
1269
1269
output. push_str ( "Box<" ) ;
1270
- push_unique_type_name ( cx , inner_type, output) ;
1270
+ push_unique_type_name ( tcx , inner_type, output) ;
1271
1271
output. push ( '>' ) ;
1272
1272
} ,
1273
1273
ty:: TyRawPtr ( ty:: TypeAndMut { ty : inner_type, mutbl } ) => {
@@ -1277,30 +1277,30 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1277
1277
hir:: MutMutable => output. push_str ( "mut " ) ,
1278
1278
}
1279
1279
1280
- push_unique_type_name ( cx , inner_type, output) ;
1280
+ push_unique_type_name ( tcx , inner_type, output) ;
1281
1281
} ,
1282
1282
ty:: TyRef ( _, ty:: TypeAndMut { ty : inner_type, mutbl } ) => {
1283
1283
output. push ( '&' ) ;
1284
1284
if mutbl == hir:: MutMutable {
1285
1285
output. push_str ( "mut " ) ;
1286
1286
}
1287
1287
1288
- push_unique_type_name ( cx , inner_type, output) ;
1288
+ push_unique_type_name ( tcx , inner_type, output) ;
1289
1289
} ,
1290
1290
ty:: TyArray ( inner_type, len) => {
1291
1291
output. push ( '[' ) ;
1292
- push_unique_type_name ( cx , inner_type, output) ;
1292
+ push_unique_type_name ( tcx , inner_type, output) ;
1293
1293
output. push_str ( & format ! ( "; {}" , len) ) ;
1294
1294
output. push ( ']' ) ;
1295
1295
} ,
1296
1296
ty:: TySlice ( inner_type) => {
1297
1297
output. push ( '[' ) ;
1298
- push_unique_type_name ( cx , inner_type, output) ;
1298
+ push_unique_type_name ( tcx , inner_type, output) ;
1299
1299
output. push ( ']' ) ;
1300
1300
} ,
1301
1301
ty:: TyTrait ( ref trait_data) => {
1302
- push_item_name ( cx , trait_data. principal . skip_binder ( ) . def_id , output) ;
1303
- push_type_params ( cx ,
1302
+ push_item_name ( tcx , trait_data. principal . skip_binder ( ) . def_id , output) ;
1303
+ push_type_params ( tcx ,
1304
1304
& trait_data. principal . skip_binder ( ) . substs . types ,
1305
1305
& trait_data. bounds . projection_bounds ,
1306
1306
output) ;
@@ -1319,10 +1319,10 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1319
1319
1320
1320
output. push_str ( "fn(" ) ;
1321
1321
1322
- let sig = cx . tcx ( ) . erase_late_bound_regions ( sig) ;
1322
+ let sig = tcx. erase_late_bound_regions ( sig) ;
1323
1323
if !sig. inputs . is_empty ( ) {
1324
1324
for & parameter_type in & sig. inputs {
1325
- push_unique_type_name ( cx , parameter_type, output) ;
1325
+ push_unique_type_name ( tcx , parameter_type, output) ;
1326
1326
output. push_str ( ", " ) ;
1327
1327
}
1328
1328
output. pop ( ) ;
@@ -1343,19 +1343,19 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1343
1343
ty:: FnConverging ( result_type) if result_type. is_nil ( ) => { }
1344
1344
ty:: FnConverging ( result_type) => {
1345
1345
output. push_str ( " -> " ) ;
1346
- push_unique_type_name ( cx , result_type, output) ;
1346
+ push_unique_type_name ( tcx , result_type, output) ;
1347
1347
}
1348
1348
ty:: FnDiverging => {
1349
1349
output. push_str ( " -> !" ) ;
1350
1350
}
1351
1351
}
1352
1352
} ,
1353
1353
ty:: TyClosure ( def_id, ref closure_substs) => {
1354
- push_item_name ( cx , def_id, output) ;
1354
+ push_item_name ( tcx , def_id, output) ;
1355
1355
output. push_str ( "{" ) ;
1356
1356
output. push_str ( & format ! ( "{}:{}" , def_id. krate, def_id. index. as_usize( ) ) ) ;
1357
1357
output. push_str ( "}" ) ;
1358
- push_type_params ( cx , & closure_substs. func_substs . types , & [ ] , output) ;
1358
+ push_type_params ( tcx , & closure_substs. func_substs . types , & [ ] , output) ;
1359
1359
}
1360
1360
ty:: TyError |
1361
1361
ty:: TyInfer ( _) |
@@ -1367,17 +1367,17 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1367
1367
}
1368
1368
}
1369
1369
1370
- fn push_item_name ( ccx : & CrateContext ,
1370
+ fn push_item_name ( tcx : & TyCtxt ,
1371
1371
def_id : DefId ,
1372
1372
output : & mut String ) {
1373
- let def_path = ccx . tcx ( ) . def_path ( def_id) ;
1373
+ let def_path = tcx. def_path ( def_id) ;
1374
1374
1375
1375
// some_crate::
1376
- output. push_str ( & ccx . tcx ( ) . crate_name ( def_path. krate ) ) ;
1376
+ output. push_str ( & tcx. crate_name ( def_path. krate ) ) ;
1377
1377
output. push_str ( "::" ) ;
1378
1378
1379
1379
// foo::bar::ItemName::
1380
- for part in ccx . tcx ( ) . def_path ( def_id) . data {
1380
+ for part in tcx. def_path ( def_id) . data {
1381
1381
output. push_str ( & format ! ( "{}[{}]::" ,
1382
1382
part. data. as_interned_str( ) ,
1383
1383
part. disambiguator) ) ;
@@ -1388,18 +1388,18 @@ fn push_item_name(ccx: &CrateContext,
1388
1388
output. pop ( ) ;
1389
1389
}
1390
1390
1391
- fn push_type_params < ' a , ' tcx > ( cx : & CrateContext < ' a , ' tcx > ,
1392
- types : & ' tcx subst:: VecPerParamSpace < Ty < ' tcx > > ,
1393
- projections : & [ ty:: PolyProjectionPredicate < ' tcx > ] ,
1394
- output : & mut String ) {
1391
+ fn push_type_params < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1392
+ types : & ' tcx subst:: VecPerParamSpace < Ty < ' tcx > > ,
1393
+ projections : & [ ty:: PolyProjectionPredicate < ' tcx > ] ,
1394
+ output : & mut String ) {
1395
1395
if types. is_empty ( ) && projections. is_empty ( ) {
1396
1396
return ;
1397
1397
}
1398
1398
1399
1399
output. push ( '<' ) ;
1400
1400
1401
1401
for & type_parameter in types {
1402
- push_unique_type_name ( cx , type_parameter, output) ;
1402
+ push_unique_type_name ( tcx , type_parameter, output) ;
1403
1403
output. push_str ( ", " ) ;
1404
1404
}
1405
1405
@@ -1408,7 +1408,7 @@ fn push_type_params<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1408
1408
let name = token:: get_ident_interner ( ) . get ( projection. projection_ty . item_name ) ;
1409
1409
output. push_str ( & name[ ..] ) ;
1410
1410
output. push_str ( "=" ) ;
1411
- push_unique_type_name ( cx , projection. ty , output) ;
1411
+ push_unique_type_name ( tcx , projection. ty , output) ;
1412
1412
output. push_str ( ", " ) ;
1413
1413
}
1414
1414
@@ -1418,24 +1418,24 @@ fn push_type_params<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
1418
1418
output. push ( '>' ) ;
1419
1419
}
1420
1420
1421
- fn push_instance_as_string < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1422
- instance : Instance < ' tcx > ,
1423
- output : & mut String ) {
1424
- push_item_name ( ccx , instance. def , output) ;
1425
- push_type_params ( ccx , & instance. substs . types , & [ ] , output) ;
1421
+ fn push_instance_as_string < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1422
+ instance : Instance < ' tcx > ,
1423
+ output : & mut String ) {
1424
+ push_item_name ( tcx , instance. def , output) ;
1425
+ push_type_params ( tcx , & instance. substs . types , & [ ] , output) ;
1426
1426
}
1427
1427
1428
- pub fn def_id_to_string ( ccx : & CrateContext , def_id : DefId ) -> String {
1428
+ pub fn def_id_to_string ( tcx : & TyCtxt , def_id : DefId ) -> String {
1429
1429
let mut output = String :: new ( ) ;
1430
- push_item_name ( ccx , def_id, & mut output) ;
1430
+ push_item_name ( tcx , def_id, & mut output) ;
1431
1431
output
1432
1432
}
1433
1433
1434
- fn type_to_string < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1435
- ty : ty:: Ty < ' tcx > )
1436
- -> String {
1434
+ fn type_to_string < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1435
+ ty : ty:: Ty < ' tcx > )
1436
+ -> String {
1437
1437
let mut output = String :: new ( ) ;
1438
- push_unique_type_name ( ccx , ty, & mut output) ;
1438
+ push_unique_type_name ( tcx , ty, & mut output) ;
1439
1439
output
1440
1440
}
1441
1441
@@ -1492,8 +1492,8 @@ impl<'tcx> TransItem<'tcx> {
1492
1492
}
1493
1493
}
1494
1494
1495
- pub fn to_string < ' a > ( & self , ccx : & CrateContext < ' a , ' tcx > ) -> String {
1496
- let hir_map = & ccx . tcx ( ) . map ;
1495
+ pub fn to_string ( & self , tcx : & TyCtxt < ' tcx > ) -> String {
1496
+ let hir_map = & tcx. map ;
1497
1497
1498
1498
return match * self {
1499
1499
TransItem :: DropGlue ( dg) => {
@@ -1502,26 +1502,26 @@ impl<'tcx> TransItem<'tcx> {
1502
1502
DropGlueKind :: Ty ( _) => s. push_str ( "drop-glue " ) ,
1503
1503
DropGlueKind :: TyContents ( _) => s. push_str ( "drop-glue-contents " ) ,
1504
1504
} ;
1505
- push_unique_type_name ( ccx , dg. ty ( ) , & mut s) ;
1505
+ push_unique_type_name ( tcx , dg. ty ( ) , & mut s) ;
1506
1506
s
1507
1507
}
1508
1508
TransItem :: Fn ( instance) => {
1509
- to_string_internal ( ccx , "fn " , instance)
1509
+ to_string_internal ( tcx , "fn " , instance)
1510
1510
} ,
1511
1511
TransItem :: Static ( node_id) => {
1512
1512
let def_id = hir_map. local_def_id ( node_id) ;
1513
- let instance = Instance :: mono ( ccx . tcx ( ) , def_id) ;
1514
- to_string_internal ( ccx , "static " , instance)
1513
+ let instance = Instance :: mono ( tcx, def_id) ;
1514
+ to_string_internal ( tcx , "static " , instance)
1515
1515
} ,
1516
1516
} ;
1517
1517
1518
- fn to_string_internal < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
1519
- prefix : & str ,
1520
- instance : Instance < ' tcx > )
1521
- -> String {
1518
+ fn to_string_internal < ' tcx > ( tcx : & TyCtxt < ' tcx > ,
1519
+ prefix : & str ,
1520
+ instance : Instance < ' tcx > )
1521
+ -> String {
1522
1522
let mut result = String :: with_capacity ( 32 ) ;
1523
1523
result. push_str ( prefix) ;
1524
- push_instance_as_string ( ccx , instance, & mut result) ;
1524
+ push_instance_as_string ( tcx , instance, & mut result) ;
1525
1525
result
1526
1526
}
1527
1527
}
@@ -1575,7 +1575,7 @@ pub fn print_collection_results<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
1575
1575
let mut item_keys = FnvHashMap ( ) ;
1576
1576
1577
1577
for ( item, item_state) in trans_items. iter ( ) {
1578
- let k = item. to_string ( & ccx) ;
1578
+ let k = item. to_string ( ccx. tcx ( ) ) ;
1579
1579
1580
1580
if item_keys. contains_key ( & k) {
1581
1581
let prev: ( TransItem , TransItemState ) = item_keys[ & k] ;
@@ -1603,7 +1603,7 @@ pub fn print_collection_results<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>) {
1603
1603
let mut generated = FnvHashSet ( ) ;
1604
1604
1605
1605
for ( item, item_state) in trans_items. iter ( ) {
1606
- let item_key = item. to_string ( & ccx) ;
1606
+ let item_key = item. to_string ( ccx. tcx ( ) ) ;
1607
1607
1608
1608
match * item_state {
1609
1609
TransItemState :: PredictedAndGenerated => {
0 commit comments