@@ -5001,7 +5001,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5001
5001
// FIXME(varkor): Separating out the parameters is messy.
5002
5002
let mut lifetimes_type_seg = vec ! [ ] ;
5003
5003
let mut types_type_seg = vec ! [ ] ;
5004
- let mut infer_types_type_seg = true ;
5004
+ let mut _infer_types_type_seg = true ;
5005
5005
if let Some ( ( seg, _) ) = type_segment {
5006
5006
if let Some ( ref data) = seg. args {
5007
5007
for ( i, arg) in data. args . iter ( ) . enumerate ( ) {
@@ -5011,12 +5011,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5011
5011
}
5012
5012
}
5013
5013
}
5014
- infer_types_type_seg = seg. infer_types ;
5014
+ _infer_types_type_seg = seg. infer_types ;
5015
5015
}
5016
5016
5017
5017
let mut lifetimes_fn_seg = vec ! [ ] ;
5018
5018
let mut types_fn_seg = vec ! [ ] ;
5019
- let mut infer_types_fn_seg = true ;
5019
+ let mut _infer_types_fn_seg = true ;
5020
5020
if let Some ( ( seg, _) ) = fn_segment {
5021
5021
if let Some ( ref data) = seg. args {
5022
5022
for ( i, arg) in data. args . iter ( ) . enumerate ( ) {
@@ -5026,7 +5026,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5026
5026
}
5027
5027
}
5028
5028
}
5029
- infer_types_fn_seg = seg. infer_types ;
5029
+ _infer_types_fn_seg = seg. infer_types ;
5030
5030
}
5031
5031
5032
5032
let defs = self . tcx . generics_of ( def. def_id ( ) ) ;
@@ -5045,74 +5045,61 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5045
5045
while let Some ( def_id) = stack. pop ( ) {
5046
5046
let defs = self . tcx . generics_of ( def_id) ;
5047
5047
Substs :: fill_single ( & mut substs, defs, & mut |param : & ty:: GenericParamDef , substs| {
5048
- let mut i = param. index as usize ;
5049
-
5050
- let ( lifetimes, types, infer_types) = if i < fn_start {
5048
+ let lifetimes = if ( param. index as usize ) < fn_start {
5051
5049
if let GenericParamDefKind :: Type { .. } = param. kind {
5052
5050
// Handle Self first, so we can adjust the index to match the AST.
5053
- if has_self && i == 0 {
5051
+ if has_self && param . index == 0 {
5054
5052
return opt_self_ty. map ( |ty| ty. into ( ) ) . unwrap_or_else ( || {
5055
5053
self . var_for_def ( span, param)
5056
5054
} ) ;
5057
5055
}
5058
5056
}
5059
- i -= has_self as usize ;
5060
- ( & lifetimes_type_seg, & types_type_seg, infer_types_type_seg)
5057
+ & lifetimes_type_seg
5061
5058
} else {
5062
- i -= fn_start;
5063
- ( & lifetimes_fn_seg, & types_fn_seg, infer_types_fn_seg)
5059
+ & lifetimes_fn_seg
5064
5060
} ;
5065
5061
5066
5062
let mut pi = param. index as usize - has_self as usize ;
5067
5063
5068
- let segment = if let Some ( & PathSeg ( _, ind) ) = path_segs. iter ( ) . find ( |& PathSeg ( di, _) | * di == def_id) {
5064
+ let ( _segment , infer_types ) = if let Some ( & PathSeg ( _, ind) ) = path_segs. iter ( ) . find ( |& PathSeg ( di, _) | * di == def_id) {
5069
5065
let seg = & segments[ ind] ;
5070
5066
if lifetimes. len ( ) == 0 {
5071
5067
pi -= defs. own_counts ( ) . lifetimes ;
5072
5068
}
5073
5069
5074
- Some ( ( seg, defs) )
5070
+ if let Some ( ref data) = seg. args {
5071
+ if let Some ( arg) = data. args . get ( pi) {
5072
+ return match param. kind {
5073
+ GenericParamDefKind :: Lifetime => {
5074
+ let lt = match arg {
5075
+ GenericArg :: Lifetime ( lt) => lt,
5076
+ _ => bug ! ( "should be a lifetime" ) ,
5077
+ } ;
5078
+ AstConv :: ast_region_to_region ( self , lt, Some ( param) ) . into ( )
5079
+ }
5080
+ GenericParamDefKind :: Type { .. } => {
5081
+ // A provided type parameter.
5082
+ let ty = match arg {
5083
+ GenericArg :: Type ( ty) => ty,
5084
+ _ => bug ! ( "should be a type" ) ,
5085
+ } ;
5086
+ self . to_ty ( ty) . into ( )
5087
+ }
5088
+ } ;
5089
+ }
5090
+ }
5091
+
5092
+ ( Some ( ( seg, defs) ) , seg. infer_types )
5075
5093
} else {
5076
- None
5094
+ ( None , true )
5077
5095
} ;
5078
5096
5079
- // eprintln!("{:?} {:?} {:?}", param.index, i, segment);
5080
-
5081
-
5082
-
5083
5097
match param. kind {
5084
5098
GenericParamDefKind :: Lifetime => {
5085
- if let Some ( ( z, lt) ) = lifetimes. get ( i) {
5086
- eprintln ! ( "lifetime {:?} {:?} {:?}" , pi, z, has_self) ;
5087
- if pi != * z {
5088
- eprintln ! ( "error {:?} {:?} {:?} {:?} {:?} {:?}" , pi, z, i, segment, fn_start, has_self) ;
5089
- bug ! ( "uh oh" )
5090
- }
5091
- AstConv :: ast_region_to_region ( self , lt, Some ( param) ) . into ( )
5092
- } else {
5093
- self . re_infer ( span, Some ( param) ) . unwrap ( ) . into ( )
5094
- }
5099
+ self . re_infer ( span, Some ( param) ) . unwrap ( ) . into ( )
5095
5100
}
5096
- GenericParamDefKind :: Type { .. } => {
5097
- // Skip over the lifetimes in the same segment.
5098
- if let Some ( ( _, generics) ) = segment {
5099
- i -= generics. own_counts ( ) . lifetimes ;
5100
- }
5101
-
5102
- let has_default = match param. kind {
5103
- GenericParamDefKind :: Type { has_default, .. } => has_default,
5104
- _ => unreachable ! ( )
5105
- } ;
5106
-
5107
- if let Some ( ( z, ty) ) = types. get ( i) {
5108
- eprintln ! ( "type {:?} {:?} {:?}" , pi, z, has_self) ;
5109
- if pi != * z {
5110
- eprintln ! ( "error {:?} {:?} {:?} {:?} {:?} {:?}" , pi, z, i, segment, fn_start, has_self) ;
5111
- bug ! ( "uh oh" )
5112
- }
5113
- // A provided type parameter.
5114
- self . to_ty ( ty) . into ( )
5115
- } else if !infer_types && has_default {
5101
+ GenericParamDefKind :: Type { has_default, .. } => {
5102
+ if !infer_types && has_default {
5116
5103
// No type parameter provided, but a default exists.
5117
5104
let default = self . tcx . type_of ( param. def_id ) ;
5118
5105
self . normalize_ty (
0 commit comments