Skip to content

Commit e02642d

Browse files
committed
Fix confirm.rs
1 parent 340a7fc commit e02642d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/librustc_typeck/check/method/confirm.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,12 +323,26 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> {
323323
// parameters from the type and those from the method.
324324
assert_eq!(method_generics.parent_count, parent_substs.len());
325325

326+
let inferred_lifetimes = if if let Some(ref data) = segment.args {
327+
!data.args.iter().any(|arg| match arg {
328+
GenericArg::Lifetime(_) => true,
329+
_ => false,
330+
})
331+
} else {
332+
true
333+
} {
334+
method_generics.own_counts().lifetimes
335+
} else {
336+
0
337+
};
338+
326339
Substs::for_item(self.tcx, pick.item.def_id, |param, _| {
327-
let i = param.index as usize;
328-
if i < parent_substs.len() {
329-
parent_substs[i]
340+
let param_idx = param.index as usize;
341+
if param_idx < parent_substs.len() {
342+
parent_substs[param_idx]
330343
} else {
331-
let param_idx = i - parent_substs.len();
344+
let param_idx = (param.index as usize - parent_substs.len())
345+
.saturating_sub(inferred_lifetimes);
332346

333347
if let Some(ref data) = segment.args {
334348
if let Some(arg) = data.args.get(param_idx) {

0 commit comments

Comments
 (0)