@@ -322,41 +322,32 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
322
322
// Create subst for early-bound lifetime parameters, combining
323
323
// parameters from the type and those from the method.
324
324
assert_eq ! ( method_generics. parent_count, parent_substs. len( ) ) ;
325
- let provided = & segment. args ;
326
- let own_counts = method_generics. own_counts ( ) ;
327
- // FIXME(varkor): Separating out the parameters is messy.
328
- let lifetimes: Vec < _ > = provided. iter ( ) . flat_map ( |data| {
329
- data. args . iter ( ) . filter_map ( |arg| match arg {
330
- GenericArg :: Lifetime ( ty) => Some ( ty) ,
331
- _ => None ,
332
- } )
333
- } ) . collect ( ) ;
334
- let types: Vec < _ > = provided. iter ( ) . flat_map ( |data| {
335
- data. args . iter ( ) . filter_map ( |arg| match arg {
336
- GenericArg :: Type ( ty) => Some ( ty) ,
337
- _ => None ,
338
- } )
339
- } ) . collect ( ) ;
325
+
340
326
Substs :: for_item ( self . tcx , pick. item . def_id , |param, _| {
341
327
let i = param. index as usize ;
342
328
if i < parent_substs. len ( ) {
343
329
parent_substs[ i]
344
330
} else {
345
- match param. kind {
346
- GenericParamDefKind :: Lifetime => {
347
- let idx = i - parent_substs. len ( ) ;
348
- if let Some ( lifetime) = lifetimes. get ( idx) {
349
- return AstConv :: ast_region_to_region (
350
- self . fcx , lifetime, Some ( param) ) . into ( ) ;
351
- }
352
- }
353
- GenericParamDefKind :: Type { .. } => {
354
- let idx = i - parent_substs. len ( ) - own_counts. lifetimes ;
355
- if let Some ( ast_ty) = types. get ( idx) {
356
- return self . to_ty ( ast_ty) . into ( ) ;
331
+ let param_idx = i - parent_substs. len ( ) ;
332
+
333
+ if let Some ( ref data) = segment. args {
334
+ if let Some ( arg) = data. args . get ( param_idx) {
335
+ match param. kind {
336
+ GenericParamDefKind :: Lifetime => match arg {
337
+ GenericArg :: Lifetime ( lt) => {
338
+ return AstConv :: ast_region_to_region (
339
+ self . fcx , lt, Some ( param) ) . into ( ) ;
340
+ }
341
+ _ => { }
342
+ }
343
+ GenericParamDefKind :: Type { .. } => match arg {
344
+ GenericArg :: Type ( ty) => return self . to_ty ( ty) . into ( ) ,
345
+ _ => { }
346
+ }
357
347
}
358
348
}
359
349
}
350
+
360
351
self . var_for_def ( self . span , param)
361
352
}
362
353
} )
0 commit comments