@@ -2121,6 +2121,10 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21212121 _ => false ,
21222122 } ;
21232123
2124+ // Only skip `Self`, `&Self` and `&mut Self`,
2125+ // and to handle other `self`s like normal arguments.
2126+ let mut should_skip = false ;
2127+
21242128 // In accordance with the rules for lifetime elision, we can determine
21252129 // what region to use for elision in the output type in two ways.
21262130 // First (determined here), if `self` is by-reference, then the
@@ -2154,19 +2158,26 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21542158 false
21552159 } ;
21562160
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+ should_skip = true ;
21672174 }
21682175 }
21692176 }
2177+ hir:: TyKind :: Path ( hir:: QPath :: Resolved ( None , ref path) ) if is_self_ty ( path. res ) => {
2178+ should_skip = true ;
2179+ }
2180+ _ => { }
21702181 }
21712182 }
21722183
@@ -2178,7 +2189,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
21782189 let arg_lifetimes = inputs
21792190 . iter ( )
21802191 . enumerate ( )
2181- . skip ( has_self as usize )
2192+ . skip ( should_skip as usize )
21822193 . map ( |( i, input) | {
21832194 let mut gather = GatherLifetimes {
21842195 map : self . map ,
0 commit comments