@@ -636,7 +636,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
636
636
637
637
debug ! ( "trait_def: ident={} trait_def={}" ,
638
638
it. ident. repr( ccx. tcx) ,
639
- trait_def. repr( ccx. tcx( ) ) ) ;
639
+ trait_def. repr( ccx. tcx) ) ;
640
640
641
641
for trait_method in trait_methods. iter ( ) {
642
642
let self_type = ty:: mk_self_type ( tcx) ;
@@ -1108,14 +1108,13 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
1108
1108
}
1109
1109
}
1110
1110
1111
- fn ty_generics_for_fn_or_method < ' tcx , AC > (
1112
- this : & AC ,
1113
- generics : & ast:: Generics ,
1114
- base_generics : ty:: Generics < ' tcx > )
1115
- -> ty:: Generics < ' tcx >
1116
- where AC : AstConv < ' tcx > {
1111
+ fn ty_generics_for_fn_or_method < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1112
+ generics : & ast:: Generics ,
1113
+ base_generics : ty:: Generics < ' tcx > )
1114
+ -> ty:: Generics < ' tcx >
1115
+ {
1117
1116
let early_lifetimes = resolve_lifetime:: early_bound_lifetimes ( generics) ;
1118
- ty_generics ( this ,
1117
+ ty_generics ( ccx ,
1119
1118
subst:: FnSpace ,
1120
1119
early_lifetimes[ ] ,
1121
1120
generics. ty_params [ ] ,
@@ -1124,11 +1123,11 @@ fn ty_generics_for_fn_or_method<'tcx,AC>(
1124
1123
}
1125
1124
1126
1125
// Add the Sized bound, unless the type parameter is marked as `?Sized`.
1127
- fn add_unsized_bound < ' tcx , AC > ( this : & AC ,
1126
+ fn add_unsized_bound < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1128
1127
bounds : & mut ty:: BuiltinBounds ,
1129
1128
ast_bounds : & [ ast:: TyParamBound ] ,
1130
1129
span : Span )
1131
- where AC : AstConv < ' tcx > {
1130
+ {
1132
1131
// Try to find an unbound in bounds.
1133
1132
let mut unbound = None ;
1134
1133
for ab in ast_bounds. iter ( ) {
@@ -1137,52 +1136,51 @@ fn add_unsized_bound<'tcx,AC>(this: &AC,
1137
1136
assert ! ( ptr. bound_lifetimes. is_empty( ) ) ;
1138
1137
unbound = Some ( ptr. trait_ref . clone ( ) ) ;
1139
1138
} else {
1140
- this . tcx ( ) . sess . span_err ( span, "type parameter has more than one relaxed default \
1139
+ ccx . tcx . sess . span_err ( span, "type parameter has more than one relaxed default \
1141
1140
bound, only one is supported") ;
1142
1141
}
1143
1142
}
1144
1143
}
1145
1144
1146
- let kind_id = this . tcx ( ) . lang_items . require ( SizedTraitLangItem ) ;
1145
+ let kind_id = ccx . tcx . lang_items . require ( SizedTraitLangItem ) ;
1147
1146
match unbound {
1148
1147
Some ( ref tpb) => {
1149
1148
// FIXME(#8559) currently requires the unbound to be built-in.
1150
- let trait_def_id = ty:: trait_ref_to_def_id ( this . tcx ( ) , tpb) ;
1149
+ let trait_def_id = ty:: trait_ref_to_def_id ( ccx . tcx , tpb) ;
1151
1150
match kind_id {
1152
1151
Ok ( kind_id) if trait_def_id != kind_id => {
1153
- this . tcx ( ) . sess . span_warn ( span,
1152
+ ccx . tcx . sess . span_warn ( span,
1154
1153
"default bound relaxed for a type parameter, but \
1155
1154
this does nothing because the given bound is not \
1156
1155
a default. Only `?Sized` is supported") ;
1157
- ty:: try_add_builtin_trait ( this . tcx ( ) ,
1156
+ ty:: try_add_builtin_trait ( ccx . tcx ,
1158
1157
kind_id,
1159
1158
bounds) ;
1160
1159
}
1161
1160
_ => { }
1162
1161
}
1163
1162
}
1164
1163
_ if kind_id. is_ok ( ) => {
1165
- ty:: try_add_builtin_trait ( this . tcx ( ) , kind_id. unwrap ( ) , bounds) ;
1164
+ ty:: try_add_builtin_trait ( ccx . tcx , kind_id. unwrap ( ) , bounds) ;
1166
1165
}
1167
1166
// No lang item for Sized, so we can't add it as a bound.
1168
1167
None => { }
1169
1168
}
1170
1169
}
1171
1170
1172
- fn ty_generics < ' tcx , AC > ( this : & AC ,
1171
+ fn ty_generics < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1173
1172
space : subst:: ParamSpace ,
1174
1173
lifetime_defs : & [ ast:: LifetimeDef ] ,
1175
1174
types : & [ ast:: TyParam ] ,
1176
1175
base_generics : ty:: Generics < ' tcx > ,
1177
1176
where_clause : & ast:: WhereClause )
1178
1177
-> ty:: Generics < ' tcx >
1179
- where AC : AstConv < ' tcx >
1180
1178
{
1181
1179
let mut result = base_generics;
1182
1180
1183
1181
for ( i, l) in lifetime_defs. iter ( ) . enumerate ( ) {
1184
1182
let bounds = l. bounds . iter ( )
1185
- . map ( |l| ast_region_to_region ( this . tcx ( ) , l) )
1183
+ . map ( |l| ast_region_to_region ( ccx . tcx , l) )
1186
1184
. collect ( ) ;
1187
1185
let def = ty:: RegionParameterDef { name : l. lifetime . name ,
1188
1186
space : space,
@@ -1197,33 +1195,33 @@ fn ty_generics<'tcx,AC>(this: &AC,
1197
1195
1198
1196
// Now create the real type parameters.
1199
1197
for ( i, param) in types. iter ( ) . enumerate ( ) {
1200
- let def = get_or_create_type_parameter_def ( this ,
1198
+ let def = get_or_create_type_parameter_def ( ccx ,
1201
1199
space,
1202
1200
param,
1203
1201
i as u32 ) ;
1204
1202
debug ! ( "ty_generics: def for type param: {}, {}" ,
1205
- def. repr( this . tcx( ) ) ,
1203
+ def. repr( ccx . tcx) ,
1206
1204
space) ;
1207
1205
result. types . push ( space, def) ;
1208
1206
}
1209
1207
1210
1208
// Just for fun, also push the bounds from the type parameters
1211
1209
// into the predicates list. This is currently kind of non-DRY.
1212
- create_predicates ( this . tcx ( ) , & mut result, space) ;
1210
+ create_predicates ( ccx . tcx , & mut result, space) ;
1213
1211
1214
1212
// Add the bounds not associated with a type parameter
1215
1213
for predicate in where_clause. predicates . iter ( ) {
1216
1214
match predicate {
1217
1215
& ast:: WherePredicate :: BoundPredicate ( ref bound_pred) => {
1218
- let ty = ast_ty_to_ty ( this , & ExplicitRscope , & * bound_pred. bounded_ty ) ;
1216
+ let ty = ast_ty_to_ty ( ccx , & ExplicitRscope , & * bound_pred. bounded_ty ) ;
1219
1217
1220
1218
for bound in bound_pred. bounds . iter ( ) {
1221
1219
match bound {
1222
1220
& ast:: TyParamBound :: TraitTyParamBound ( ref poly_trait_ref, _) => {
1223
1221
let mut projections = Vec :: new ( ) ;
1224
1222
1225
1223
let trait_ref = astconv:: instantiate_poly_trait_ref (
1226
- this ,
1224
+ ccx ,
1227
1225
& ExplicitRscope ,
1228
1226
poly_trait_ref,
1229
1227
Some ( ty) ,
@@ -1238,7 +1236,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
1238
1236
}
1239
1237
1240
1238
& ast:: TyParamBound :: RegionTyParamBound ( ref lifetime) => {
1241
- let region = ast_region_to_region ( this . tcx ( ) , lifetime) ;
1239
+ let region = ast_region_to_region ( ccx . tcx , lifetime) ;
1242
1240
let pred = ty:: Binder ( ty:: OutlivesPredicate ( ty, region) ) ;
1243
1241
result. predicates . push ( space, ty:: Predicate :: TypeOutlives ( pred) )
1244
1242
}
@@ -1247,17 +1245,17 @@ fn ty_generics<'tcx,AC>(this: &AC,
1247
1245
}
1248
1246
1249
1247
& ast:: WherePredicate :: RegionPredicate ( ref region_pred) => {
1250
- let r1 = ast_region_to_region ( this . tcx ( ) , & region_pred. lifetime ) ;
1248
+ let r1 = ast_region_to_region ( ccx . tcx , & region_pred. lifetime ) ;
1251
1249
for bound in region_pred. bounds . iter ( ) {
1252
- let r2 = ast_region_to_region ( this . tcx ( ) , bound) ;
1250
+ let r2 = ast_region_to_region ( ccx . tcx , bound) ;
1253
1251
let pred = ty:: Binder ( ty:: OutlivesPredicate ( r1, r2) ) ;
1254
1252
result. predicates . push ( space, ty:: Predicate :: RegionOutlives ( pred) )
1255
1253
}
1256
1254
}
1257
1255
1258
1256
& ast:: WherePredicate :: EqPredicate ( ref eq_pred) => {
1259
1257
// FIXME(#20041)
1260
- this . tcx ( ) . sess . span_bug ( eq_pred. span ,
1258
+ ccx . tcx . sess . span_bug ( eq_pred. span ,
1261
1259
"Equality constraints are not yet \
1262
1260
implemented (#20041)")
1263
1261
}
@@ -1292,34 +1290,33 @@ fn ty_generics<'tcx,AC>(this: &AC,
1292
1290
}
1293
1291
}
1294
1292
1295
- fn get_or_create_type_parameter_def < ' tcx , AC > ( this : & AC ,
1293
+ fn get_or_create_type_parameter_def < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1296
1294
space : subst:: ParamSpace ,
1297
1295
param : & ast:: TyParam ,
1298
1296
index : u32 )
1299
1297
-> ty:: TypeParameterDef < ' tcx >
1300
- where AC : AstConv < ' tcx >
1301
1298
{
1302
- match this . tcx ( ) . ty_param_defs . borrow ( ) . get ( & param. id ) {
1299
+ match ccx . tcx . ty_param_defs . borrow ( ) . get ( & param. id ) {
1303
1300
Some ( d) => { return ( * d) . clone ( ) ; }
1304
1301
None => { }
1305
1302
}
1306
1303
1307
1304
let param_ty = ty:: ParamTy :: new ( space, index, param. ident . name ) ;
1308
- let bounds = compute_bounds ( this ,
1309
- param_ty. to_ty ( this . tcx ( ) ) ,
1305
+ let bounds = compute_bounds ( ccx ,
1306
+ param_ty. to_ty ( ccx . tcx ) ,
1310
1307
param. bounds [ ] ,
1311
1308
SizedByDefault :: Yes ,
1312
1309
param. span ) ;
1313
1310
let default = match param. default {
1314
1311
None => None ,
1315
1312
Some ( ref path) => {
1316
- let ty = ast_ty_to_ty ( this , & ExplicitRscope , & * * path) ;
1313
+ let ty = ast_ty_to_ty ( ccx , & ExplicitRscope , & * * path) ;
1317
1314
let cur_idx = index;
1318
1315
1319
1316
ty:: walk_ty ( ty, |t| {
1320
1317
match t. sty {
1321
1318
ty:: ty_param( p) => if p. idx > cur_idx {
1322
- span_err ! ( this . tcx( ) . sess, path. span, E0128 ,
1319
+ span_err ! ( ccx . tcx. sess, path. span, E0128 ,
1323
1320
"type parameters with a default cannot use \
1324
1321
forward declared identifiers") ;
1325
1322
} ,
@@ -1340,7 +1337,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
1340
1337
default : default
1341
1338
} ;
1342
1339
1343
- this . tcx ( ) . ty_param_defs . borrow_mut ( ) . insert ( param. id , def. clone ( ) ) ;
1340
+ ccx . tcx . ty_param_defs . borrow_mut ( ) . insert ( param. id , def. clone ( ) ) ;
1344
1341
1345
1342
def
1346
1343
}
@@ -1350,26 +1347,25 @@ enum SizedByDefault { Yes, No }
1350
1347
/// Translate the AST's notion of ty param bounds (which are an enum consisting of a newtyped Ty or
1351
1348
/// a region) to ty's notion of ty param bounds, which can either be user-defined traits, or the
1352
1349
/// built-in trait (formerly known as kind): Send.
1353
- fn compute_bounds < ' tcx , AC > ( this : & AC ,
1350
+ fn compute_bounds < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1354
1351
param_ty : ty:: Ty < ' tcx > ,
1355
1352
ast_bounds : & [ ast:: TyParamBound ] ,
1356
1353
sized_by_default : SizedByDefault ,
1357
1354
span : Span )
1358
1355
-> ty:: ParamBounds < ' tcx >
1359
- where AC : AstConv < ' tcx >
1360
1356
{
1361
- let mut param_bounds = conv_param_bounds ( this ,
1357
+ let mut param_bounds = conv_param_bounds ( ccx ,
1362
1358
span,
1363
1359
param_ty,
1364
1360
ast_bounds) ;
1365
1361
1366
1362
if let SizedByDefault :: Yes = sized_by_default {
1367
- add_unsized_bound ( this ,
1363
+ add_unsized_bound ( ccx ,
1368
1364
& mut param_bounds. builtin_bounds ,
1369
1365
ast_bounds,
1370
1366
span) ;
1371
1367
1372
- check_bounds_compatible ( this . tcx ( ) ,
1368
+ check_bounds_compatible ( ccx . tcx ,
1373
1369
param_ty,
1374
1370
& param_bounds,
1375
1371
span) ;
@@ -1404,24 +1400,23 @@ fn check_bounds_compatible<'tcx>(tcx: &ty::ctxt<'tcx>,
1404
1400
}
1405
1401
}
1406
1402
1407
- fn conv_param_bounds < ' tcx , AC > ( this : & AC ,
1403
+ fn conv_param_bounds < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
1408
1404
span : Span ,
1409
1405
param_ty : ty:: Ty < ' tcx > ,
1410
1406
ast_bounds : & [ ast:: TyParamBound ] )
1411
1407
-> ty:: ParamBounds < ' tcx >
1412
- where AC : AstConv < ' tcx >
1413
1408
{
1414
1409
let astconv:: PartitionedBounds { builtin_bounds,
1415
1410
trait_bounds,
1416
1411
region_bounds } =
1417
- astconv:: partition_bounds ( this . tcx ( ) , span, ast_bounds. as_slice ( ) ) ;
1412
+ astconv:: partition_bounds ( ccx . tcx , span, ast_bounds. as_slice ( ) ) ;
1418
1413
1419
1414
let mut projection_bounds = Vec :: new ( ) ;
1420
1415
1421
1416
let trait_bounds: Vec < ty:: PolyTraitRef > =
1422
1417
trait_bounds. into_iter ( )
1423
1418
. map ( |bound| {
1424
- astconv:: instantiate_poly_trait_ref ( this ,
1419
+ astconv:: instantiate_poly_trait_ref ( ccx ,
1425
1420
& ExplicitRscope ,
1426
1421
bound,
1427
1422
Some ( param_ty) ,
@@ -1430,7 +1425,7 @@ fn conv_param_bounds<'tcx,AC>(this: &AC,
1430
1425
. collect ( ) ;
1431
1426
let region_bounds: Vec < ty:: Region > =
1432
1427
region_bounds. into_iter ( )
1433
- . map ( |r| ast_region_to_region ( this . tcx ( ) , r) )
1428
+ . map ( |r| ast_region_to_region ( ccx . tcx , r) )
1434
1429
. collect ( ) ;
1435
1430
ty:: ParamBounds {
1436
1431
region_bounds : region_bounds,
0 commit comments