about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-07-03 19:55:28 +0100
committervarkor <github@varkor.com>2018-08-19 20:02:32 +0100
commite02642dbb32dff0c0c2294f6953975e3e04ef696 (patch)
tree8a7bcd24caf54d1cdff3de031ad15708d917be26
parent340a7fc4f5c9c8c9e8526d16c8a20ff48e0b514f (diff)
Fix confirm.rs
-rw-r--r--src/librustc_typeck/check/method/confirm.rs22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs
index aa2147e9450..c9ac02928b3 100644
--- a/src/librustc_typeck/check/method/confirm.rs
+++ b/src/librustc_typeck/check/method/confirm.rs
@@ -323,12 +323,26 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
         // parameters from the type and those from the method.
         assert_eq!(method_generics.parent_count, parent_substs.len());
 
+        let inferred_lifetimes = if if let Some(ref data) = segment.args {
+            !data.args.iter().any(|arg| match arg {
+                GenericArg::Lifetime(_) => true,
+                _ => false,
+            })
+        } else {
+            true
+        } {
+            method_generics.own_counts().lifetimes
+        } else {
+            0
+        };
+
         Substs::for_item(self.tcx, pick.item.def_id, |param, _| {
-            let i = param.index as usize;
-            if i < parent_substs.len() {
-                parent_substs[i]
+            let param_idx = param.index as usize;
+            if param_idx < parent_substs.len() {
+                parent_substs[param_idx]
             } else {
-                let param_idx = i - parent_substs.len();
+                let param_idx = (param.index as usize - parent_substs.len())
+                    .saturating_sub(inferred_lifetimes);
 
                 if let Some(ref data) = segment.args {
                     if let Some(arg) = data.args.get(param_idx) {