@@ -2121,6 +2121,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
2121
2121
_ => false ,
2122
2122
} ;
2123
2123
2124
+ // Only skip `Self`, `&Self` and `&mut Self`,
2125
+ // and to handle other `self`s like normal arguments.
2126
+ let mut skip = 0 ;
2127
+
2124
2128
// In accordance with the rules for lifetime elision, we can determine
2125
2129
// what region to use for elision in the output type in two ways.
2126
2130
// First (determined here), if `self` is by-reference, then the
@@ -2154,19 +2158,26 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
2154
2158
false
2155
2159
} ;
2156
2160
2157
- if let hir:: TyKind :: Rptr ( lifetime_ref, ref mt) = inputs[ 0 ] . node {
2158
- if let hir:: TyKind :: Path ( hir:: QPath :: Resolved ( None , ref path) ) = mt. ty . node {
2159
- if is_self_ty ( path. res ) {
2160
- if let Some ( & lifetime) = self . map . defs . get ( & lifetime_ref. hir_id ) {
2161
- let scope = Scope :: Elision {
2162
- elide : Elide :: Exact ( lifetime) ,
2163
- s : self . scope ,
2164
- } ;
2165
- self . with ( scope, |_, this| this. visit_ty ( output) ) ;
2166
- return ;
2161
+ match inputs[ 0 ] . node {
2162
+ hir:: TyKind :: Rptr ( lifetime_ref, ref mt) => {
2163
+ if let hir:: TyKind :: Path ( hir:: QPath :: Resolved ( None , ref path) ) = mt. ty . node {
2164
+ if is_self_ty ( path. res ) {
2165
+ if let Some ( & lifetime) = self . map . defs . get ( & lifetime_ref. hir_id ) {
2166
+ let scope = Scope :: Elision {
2167
+ elide : Elide :: Exact ( lifetime) ,
2168
+ s : self . scope ,
2169
+ } ;
2170
+ self . with ( scope, |_, this| this. visit_ty ( output) ) ;
2171
+ return ;
2172
+ }
2173
+ skip = 1 ;
2167
2174
}
2168
2175
}
2169
2176
}
2177
+ hir:: TyKind :: Path ( hir:: QPath :: Resolved ( None , ref path) ) if is_self_ty ( path. res ) => {
2178
+ skip = 1 ;
2179
+ }
2180
+ _ => { }
2170
2181
}
2171
2182
}
2172
2183
@@ -2178,7 +2189,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
2178
2189
let arg_lifetimes = inputs
2179
2190
. iter ( )
2180
2191
. enumerate ( )
2181
- . skip ( has_self as usize )
2192
+ . skip ( skip )
2182
2193
. map ( |( i, input) | {
2183
2194
let mut gather = GatherLifetimes {
2184
2195
map : self . map ,
0 commit comments