Skip to content

Commit 5f2588f

Browse files
committed
Fix behaviour in error condition
1 parent db94efa commit 5f2588f

File tree

1 file changed

+11
-9
lines changed
  • src/librustc_typeck/check

1 file changed

+11
-9
lines changed

src/librustc_typeck/check/mod.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4987,24 +4987,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
49874987
}
49884988
};
49894989
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();
49924992
if has_self {
4993-
if let Some(param) = params.peek() {
4993+
if let Some(param) = next_param {
49944994
if param.index == 0 {
49954995
if let GenericParamDefKind::Type { .. } = param.kind {
49964996
// Handle `Self` first, so we can adjust the index to match the AST.
49974997
push_to_substs!(opt_self_ty.map(|ty| ty.into()).unwrap_or_else(|| {
49984998
self.var_for_def(span, param)
49994999
}));
5000-
remove_self = true;
5000+
next_param = params.next();
50015001
}
50025002
}
50035003
}
50045004
}
5005-
if remove_self {
5006-
params.next();
5007-
}
50085005

50095006
let mut infer_types = true;
50105007
if let Some(&PathSeg(_, index)) = path_segs
@@ -5015,29 +5012,33 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50155012
if let Some(ref data) = segments[index].args {
50165013
let args = &data.args;
50175014
'args: for arg in args {
5018-
while let Some(param) = params.next() {
5015+
while let Some(param) = next_param {
50195016
match param.kind {
50205017
GenericParamDefKind::Lifetime => match arg {
50215018
GenericArg::Lifetime(lt) => {
50225019
push_to_substs!(AstConv::ast_region_to_region(self,
50235020
lt, Some(param)).into());
5021+
next_param = params.next();
50245022
continue 'args;
50255023
}
50265024
GenericArg::Type(_) => {
50275025
// We're inferring a lifetime.
50285026
push_to_substs!(
50295027
self.re_infer(span, Some(param)).unwrap().into());
5028+
next_param = params.next();
50305029
}
50315030
}
50325031
GenericParamDefKind::Type { .. } => match arg {
50335032
GenericArg::Type(ty) => {
50345033
push_to_substs!(self.to_ty(ty).into());
5034+
next_param = params.next();
50355035
continue 'args;
50365036
}
50375037
GenericArg::Lifetime(_) => {
50385038
self.tcx.sess.delay_span_bug(span,
50395039
"found a GenericArg::Lifetime where a \
50405040
GenericArg::Type was expected");
5041+
break 'args;
50415042
}
50425043
}
50435044
}
@@ -5051,7 +5052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50515052
}
50525053
}
50535054

5054-
while let Some(param) = params.next() {
5055+
while let Some(param) = next_param {
50555056
match param.kind {
50565057
GenericParamDefKind::Lifetime => {
50575058
push_to_substs!(self.re_infer(span, Some(param)).unwrap().into());
@@ -5073,6 +5074,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
50735074
}
50745075
}
50755076
}
5077+
next_param = params.next();
50765078
}
50775079
}
50785080
let substs = self.tcx.intern_substs(&substs);

0 commit comments

Comments
 (0)