@@ -4951,14 +4951,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4951
4951
let supress_mismatch = self . check_impl_trait ( span, seg, & generics) ;
4952
4952
supress_errors. insert ( index,
4953
4953
self . check_generic_arg_count ( span, seg, & generics, false , supress_mismatch) ) ;
4954
- infer_lifetimes . insert ( index , if let Some ( ref data) = seg. args {
4954
+ let inferred_lifetimes = if if let Some ( ref data) = seg. args {
4955
4955
!data. args . iter ( ) . any ( |arg| match arg {
4956
4956
GenericArg :: Lifetime ( _) => true ,
4957
4957
_ => false ,
4958
4958
} )
4959
4959
} else {
4960
4960
true
4961
- } ) ;
4961
+ } {
4962
+ generics. own_counts ( ) . lifetimes
4963
+ } else {
4964
+ 0
4965
+ } ;
4966
+ infer_lifetimes. insert ( index, inferred_lifetimes) ;
4962
4967
}
4963
4968
4964
4969
let has_self = path_segs. last ( ) . map ( |PathSeg ( def_id, _) | {
@@ -4997,15 +5002,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
4997
5002
true
4998
5003
} else {
4999
5004
if let Some ( ref data) = segments[ index] . args {
5000
- let lifetime_offset = if infer_lifetimes[ & index] {
5001
- defs. own_counts ( ) . lifetimes
5002
- } else {
5003
- 0
5004
- } ;
5005
5005
let self_offset = ( defs. parent_count == 0 && has_self) as usize ;
5006
5006
let param_idx =
5007
5007
( param. index as usize - defs. parent_count - self_offset as usize )
5008
- . saturating_sub ( lifetime_offset ) ;
5008
+ . saturating_sub ( infer_lifetimes [ & index ] ) ;
5009
5009
if let Some ( arg) = data. args . get ( param_idx) {
5010
5010
match param. kind {
5011
5011
GenericParamDefKind :: Lifetime => match arg {
0 commit comments