@@ -636,7 +636,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) {
636636
637637 debug ! ( "trait_def: ident={} trait_def={}" ,
638638 it. ident. repr( ccx. tcx) ,
639- trait_def. repr( ccx. tcx( ) ) ) ;
639+ trait_def. repr( ccx. tcx) ) ;
640640
641641 for trait_method in trait_methods. iter ( ) {
642642 let self_type = ty:: mk_self_type ( tcx) ;
@@ -1108,14 +1108,13 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
11081108 }
11091109}
11101110
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+ {
11171116 let early_lifetimes = resolve_lifetime:: early_bound_lifetimes ( generics) ;
1118- ty_generics ( this ,
1117+ ty_generics ( ccx ,
11191118 subst:: FnSpace ,
11201119 early_lifetimes[ ] ,
11211120 generics. ty_params [ ] ,
@@ -1124,11 +1123,11 @@ fn ty_generics_for_fn_or_method<'tcx,AC>(
11241123}
11251124
11261125// 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 > ,
11281127 bounds : & mut ty:: BuiltinBounds ,
11291128 ast_bounds : & [ ast:: TyParamBound ] ,
11301129 span : Span )
1131- where AC : AstConv < ' tcx > {
1130+ {
11321131 // Try to find an unbound in bounds.
11331132 let mut unbound = None ;
11341133 for ab in ast_bounds. iter ( ) {
@@ -1137,52 +1136,51 @@ fn add_unsized_bound<'tcx,AC>(this: &AC,
11371136 assert ! ( ptr. bound_lifetimes. is_empty( ) ) ;
11381137 unbound = Some ( ptr. trait_ref . clone ( ) ) ;
11391138 } 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 \
11411140 bound, only one is supported") ;
11421141 }
11431142 }
11441143 }
11451144
1146- let kind_id = this . tcx ( ) . lang_items . require ( SizedTraitLangItem ) ;
1145+ let kind_id = ccx . tcx . lang_items . require ( SizedTraitLangItem ) ;
11471146 match unbound {
11481147 Some ( ref tpb) => {
11491148 // 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) ;
11511150 match kind_id {
11521151 Ok ( kind_id) if trait_def_id != kind_id => {
1153- this . tcx ( ) . sess . span_warn ( span,
1152+ ccx . tcx . sess . span_warn ( span,
11541153 "default bound relaxed for a type parameter, but \
11551154 this does nothing because the given bound is not \
11561155 a default. Only `?Sized` is supported") ;
1157- ty:: try_add_builtin_trait ( this . tcx ( ) ,
1156+ ty:: try_add_builtin_trait ( ccx . tcx ,
11581157 kind_id,
11591158 bounds) ;
11601159 }
11611160 _ => { }
11621161 }
11631162 }
11641163 _ 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) ;
11661165 }
11671166 // No lang item for Sized, so we can't add it as a bound.
11681167 None => { }
11691168 }
11701169}
11711170
1172- fn ty_generics < ' tcx , AC > ( this : & AC ,
1171+ fn ty_generics < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
11731172 space : subst:: ParamSpace ,
11741173 lifetime_defs : & [ ast:: LifetimeDef ] ,
11751174 types : & [ ast:: TyParam ] ,
11761175 base_generics : ty:: Generics < ' tcx > ,
11771176 where_clause : & ast:: WhereClause )
11781177 -> ty:: Generics < ' tcx >
1179- where AC : AstConv < ' tcx >
11801178{
11811179 let mut result = base_generics;
11821180
11831181 for ( i, l) in lifetime_defs. iter ( ) . enumerate ( ) {
11841182 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) )
11861184 . collect ( ) ;
11871185 let def = ty:: RegionParameterDef { name : l. lifetime . name ,
11881186 space : space,
@@ -1197,33 +1195,33 @@ fn ty_generics<'tcx,AC>(this: &AC,
11971195
11981196 // Now create the real type parameters.
11991197 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 ,
12011199 space,
12021200 param,
12031201 i as u32 ) ;
12041202 debug ! ( "ty_generics: def for type param: {}, {}" ,
1205- def. repr( this . tcx( ) ) ,
1203+ def. repr( ccx . tcx) ,
12061204 space) ;
12071205 result. types . push ( space, def) ;
12081206 }
12091207
12101208 // Just for fun, also push the bounds from the type parameters
12111209 // 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) ;
12131211
12141212 // Add the bounds not associated with a type parameter
12151213 for predicate in where_clause. predicates . iter ( ) {
12161214 match predicate {
12171215 & 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 ) ;
12191217
12201218 for bound in bound_pred. bounds . iter ( ) {
12211219 match bound {
12221220 & ast:: TyParamBound :: TraitTyParamBound ( ref poly_trait_ref, _) => {
12231221 let mut projections = Vec :: new ( ) ;
12241222
12251223 let trait_ref = astconv:: instantiate_poly_trait_ref (
1226- this ,
1224+ ccx ,
12271225 & ExplicitRscope ,
12281226 poly_trait_ref,
12291227 Some ( ty) ,
@@ -1238,7 +1236,7 @@ fn ty_generics<'tcx,AC>(this: &AC,
12381236 }
12391237
12401238 & 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) ;
12421240 let pred = ty:: Binder ( ty:: OutlivesPredicate ( ty, region) ) ;
12431241 result. predicates . push ( space, ty:: Predicate :: TypeOutlives ( pred) )
12441242 }
@@ -1247,17 +1245,17 @@ fn ty_generics<'tcx,AC>(this: &AC,
12471245 }
12481246
12491247 & 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 ) ;
12511249 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) ;
12531251 let pred = ty:: Binder ( ty:: OutlivesPredicate ( r1, r2) ) ;
12541252 result. predicates . push ( space, ty:: Predicate :: RegionOutlives ( pred) )
12551253 }
12561254 }
12571255
12581256 & ast:: WherePredicate :: EqPredicate ( ref eq_pred) => {
12591257 // FIXME(#20041)
1260- this . tcx ( ) . sess . span_bug ( eq_pred. span ,
1258+ ccx . tcx . sess . span_bug ( eq_pred. span ,
12611259 "Equality constraints are not yet \
12621260 implemented (#20041)")
12631261 }
@@ -1292,34 +1290,33 @@ fn ty_generics<'tcx,AC>(this: &AC,
12921290 }
12931291}
12941292
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 > ,
12961294 space : subst:: ParamSpace ,
12971295 param : & ast:: TyParam ,
12981296 index : u32 )
12991297 -> ty:: TypeParameterDef < ' tcx >
1300- where AC : AstConv < ' tcx >
13011298{
1302- match this . tcx ( ) . ty_param_defs . borrow ( ) . get ( & param. id ) {
1299+ match ccx . tcx . ty_param_defs . borrow ( ) . get ( & param. id ) {
13031300 Some ( d) => { return ( * d) . clone ( ) ; }
13041301 None => { }
13051302 }
13061303
13071304 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 ) ,
13101307 param. bounds [ ] ,
13111308 SizedByDefault :: Yes ,
13121309 param. span ) ;
13131310 let default = match param. default {
13141311 None => None ,
13151312 Some ( ref path) => {
1316- let ty = ast_ty_to_ty ( this , & ExplicitRscope , & * * path) ;
1313+ let ty = ast_ty_to_ty ( ccx , & ExplicitRscope , & * * path) ;
13171314 let cur_idx = index;
13181315
13191316 ty:: walk_ty ( ty, |t| {
13201317 match t. sty {
13211318 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 ,
13231320 "type parameters with a default cannot use \
13241321 forward declared identifiers") ;
13251322 } ,
@@ -1340,7 +1337,7 @@ fn get_or_create_type_parameter_def<'tcx,AC>(this: &AC,
13401337 default : default
13411338 } ;
13421339
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 ( ) ) ;
13441341
13451342 def
13461343}
@@ -1350,26 +1347,25 @@ enum SizedByDefault { Yes, No }
13501347/// Translate the AST's notion of ty param bounds (which are an enum consisting of a newtyped Ty or
13511348/// a region) to ty's notion of ty param bounds, which can either be user-defined traits, or the
13521349/// 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 > ,
13541351 param_ty : ty:: Ty < ' tcx > ,
13551352 ast_bounds : & [ ast:: TyParamBound ] ,
13561353 sized_by_default : SizedByDefault ,
13571354 span : Span )
13581355 -> ty:: ParamBounds < ' tcx >
1359- where AC : AstConv < ' tcx >
13601356{
1361- let mut param_bounds = conv_param_bounds ( this ,
1357+ let mut param_bounds = conv_param_bounds ( ccx ,
13621358 span,
13631359 param_ty,
13641360 ast_bounds) ;
13651361
13661362 if let SizedByDefault :: Yes = sized_by_default {
1367- add_unsized_bound ( this ,
1363+ add_unsized_bound ( ccx ,
13681364 & mut param_bounds. builtin_bounds ,
13691365 ast_bounds,
13701366 span) ;
13711367
1372- check_bounds_compatible ( this . tcx ( ) ,
1368+ check_bounds_compatible ( ccx . tcx ,
13731369 param_ty,
13741370 & param_bounds,
13751371 span) ;
@@ -1404,24 +1400,23 @@ fn check_bounds_compatible<'tcx>(tcx: &ty::ctxt<'tcx>,
14041400 }
14051401}
14061402
1407- fn conv_param_bounds < ' tcx , AC > ( this : & AC ,
1403+ fn conv_param_bounds < ' a , ' tcx > ( ccx : & CrateCtxt < ' a , ' tcx > ,
14081404 span : Span ,
14091405 param_ty : ty:: Ty < ' tcx > ,
14101406 ast_bounds : & [ ast:: TyParamBound ] )
14111407 -> ty:: ParamBounds < ' tcx >
1412- where AC : AstConv < ' tcx >
14131408{
14141409 let astconv:: PartitionedBounds { builtin_bounds,
14151410 trait_bounds,
14161411 region_bounds } =
1417- astconv:: partition_bounds ( this . tcx ( ) , span, ast_bounds. as_slice ( ) ) ;
1412+ astconv:: partition_bounds ( ccx . tcx , span, ast_bounds. as_slice ( ) ) ;
14181413
14191414 let mut projection_bounds = Vec :: new ( ) ;
14201415
14211416 let trait_bounds: Vec < ty:: PolyTraitRef > =
14221417 trait_bounds. into_iter ( )
14231418 . map ( |bound| {
1424- astconv:: instantiate_poly_trait_ref ( this ,
1419+ astconv:: instantiate_poly_trait_ref ( ccx ,
14251420 & ExplicitRscope ,
14261421 bound,
14271422 Some ( param_ty) ,
@@ -1430,7 +1425,7 @@ fn conv_param_bounds<'tcx,AC>(this: &AC,
14301425 . collect ( ) ;
14311426 let region_bounds: Vec < ty:: Region > =
14321427 region_bounds. into_iter ( )
1433- . map ( |r| ast_region_to_region ( this . tcx ( ) , r) )
1428+ . map ( |r| ast_region_to_region ( ccx . tcx , r) )
14341429 . collect ( ) ;
14351430 ty:: ParamBounds {
14361431 region_bounds : region_bounds,
0 commit comments