@@ -4987,24 +4987,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4987
4987
}
4988
4988
} ;
4989
4989
while let Some ( ( def_id, defs) ) = stack. pop ( ) {
4990
- let mut params = defs. params . iter ( ) . peekable ( ) ;
4991
- let mut remove_self = false ;
4990
+ let mut params = defs. params . iter ( ) ;
4991
+ let mut next_param = params . next ( ) ;
4992
4992
if has_self {
4993
- if let Some ( param) = params . peek ( ) {
4993
+ if let Some ( param) = next_param {
4994
4994
if param. index == 0 {
4995
4995
if let GenericParamDefKind :: Type { .. } = param. kind {
4996
4996
// Handle `Self` first, so we can adjust the index to match the AST.
4997
4997
push_to_substs ! ( opt_self_ty. map( |ty| ty. into( ) ) . unwrap_or_else( || {
4998
4998
self . var_for_def( span, param)
4999
4999
} ) ) ;
5000
- remove_self = true ;
5000
+ next_param = params . next ( ) ;
5001
5001
}
5002
5002
}
5003
5003
}
5004
5004
}
5005
- if remove_self {
5006
- params. next ( ) ;
5007
- }
5008
5005
5009
5006
let mut infer_types = true ;
5010
5007
if let Some ( & PathSeg ( _, index) ) = path_segs
@@ -5015,29 +5012,33 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5015
5012
if let Some ( ref data) = segments[ index] . args {
5016
5013
let args = & data. args ;
5017
5014
' args: for arg in args {
5018
- while let Some ( param) = params . next ( ) {
5015
+ while let Some ( param) = next_param {
5019
5016
match param. kind {
5020
5017
GenericParamDefKind :: Lifetime => match arg {
5021
5018
GenericArg :: Lifetime ( lt) => {
5022
5019
push_to_substs ! ( AstConv :: ast_region_to_region( self ,
5023
5020
lt, Some ( param) ) . into( ) ) ;
5021
+ next_param = params. next ( ) ;
5024
5022
continue ' args;
5025
5023
}
5026
5024
GenericArg :: Type ( _) => {
5027
5025
// We're inferring a lifetime.
5028
5026
push_to_substs ! (
5029
5027
self . re_infer( span, Some ( param) ) . unwrap( ) . into( ) ) ;
5028
+ next_param = params. next ( ) ;
5030
5029
}
5031
5030
}
5032
5031
GenericParamDefKind :: Type { .. } => match arg {
5033
5032
GenericArg :: Type ( ty) => {
5034
5033
push_to_substs ! ( self . to_ty( ty) . into( ) ) ;
5034
+ next_param = params. next ( ) ;
5035
5035
continue ' args;
5036
5036
}
5037
5037
GenericArg :: Lifetime ( _) => {
5038
5038
self . tcx . sess . delay_span_bug ( span,
5039
5039
"found a GenericArg::Lifetime where a \
5040
5040
GenericArg::Type was expected") ;
5041
+ break ' args;
5041
5042
}
5042
5043
}
5043
5044
}
@@ -5051,7 +5052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5051
5052
}
5052
5053
}
5053
5054
5054
- while let Some ( param) = params . next ( ) {
5055
+ while let Some ( param) = next_param {
5055
5056
match param. kind {
5056
5057
GenericParamDefKind :: Lifetime => {
5057
5058
push_to_substs ! ( self . re_infer( span, Some ( param) ) . unwrap( ) . into( ) ) ;
@@ -5073,6 +5074,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
5073
5074
}
5074
5075
}
5075
5076
}
5077
+ next_param = params. next ( ) ;
5076
5078
}
5077
5079
}
5078
5080
let substs = self . tcx . intern_substs ( & substs) ;
0 commit comments