about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-07-23 23:55:24 +0100
committervarkor <github@varkor.com>2018-08-19 20:02:33 +0100
commit5f2588f020c3da7b1d5c6ec089b833ca424ad403 (patch)
tree943868d0fd407495213c82f00d69c1331dc544bd
parentdb94efab39438278b77c990972978a7b00bdb9b9 (diff)
downloadrust-5f2588f020c3da7b1d5c6ec089b833ca424ad403.tar.gz
rust-5f2588f020c3da7b1d5c6ec089b833ca424ad403.zip
Fix behaviour in error condition
-rw-r--r--src/librustc_typeck/check/mod.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
index fd3281d2c0e..647e7b4a70f 100644
--- a/src/librustc_typeck/check/mod.rs
+++ b/src/librustc_typeck/check/mod.rs
@@ -4987,24 +4987,21 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
             }
         };
         while let Some((def_id, defs)) = stack.pop() {
-            let mut params = defs.params.iter().peekable();
-            let mut remove_self = false;
+            let mut params = defs.params.iter();
+            let mut next_param = params.next();
             if has_self {
-                if let Some(param) = params.peek() {
+                if let Some(param) = next_param {
                     if param.index == 0 {
                         if let GenericParamDefKind::Type { .. } = param.kind {
                             // Handle `Self` first, so we can adjust the index to match the AST.
                             push_to_substs!(opt_self_ty.map(|ty| ty.into()).unwrap_or_else(|| {
                                 self.var_for_def(span, param)
                             }));
-                            remove_self = true;
+                            next_param = params.next();
                         }
                     }
                 }
             }
-            if remove_self {
-                params.next();
-            }
 
             let mut infer_types = true;
             if let Some(&PathSeg(_, index)) = path_segs
@@ -5015,29 +5012,33 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                     if let Some(ref data) = segments[index].args {
                         let args = &data.args;
                         'args: for arg in args {
-                            while let Some(param) = params.next() {
+                            while let Some(param) = next_param {
                                 match param.kind {
                                     GenericParamDefKind::Lifetime => match arg {
                                         GenericArg::Lifetime(lt) => {
                                             push_to_substs!(AstConv::ast_region_to_region(self,
                                                 lt, Some(param)).into());
+                                            next_param = params.next();
                                             continue 'args;
                                         }
                                         GenericArg::Type(_) => {
                                             // We're inferring a lifetime.
                                             push_to_substs!(
                                                 self.re_infer(span, Some(param)).unwrap().into());
+                                            next_param = params.next();
                                         }
                                     }
                                     GenericParamDefKind::Type { .. } => match arg {
                                         GenericArg::Type(ty) => {
                                             push_to_substs!(self.to_ty(ty).into());
+                                            next_param = params.next();
                                             continue 'args;
                                         }
                                         GenericArg::Lifetime(_) => {
                                             self.tcx.sess.delay_span_bug(span,
                                                 "found a GenericArg::Lifetime where a \
                                                  GenericArg::Type was expected");
+                                            break 'args;
                                         }
                                     }
                                 }
@@ -5051,7 +5052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                 }
             }
 
-            while let Some(param) = params.next() {
+            while let Some(param) = next_param {
                 match param.kind {
                     GenericParamDefKind::Lifetime => {
                         push_to_substs!(self.re_infer(span, Some(param)).unwrap().into());
@@ -5073,6 +5074,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
                         }
                     }
                 }
+                next_param = params.next();
             }
         }
         let substs = self.tcx.intern_substs(&substs);