@@ -2105,13 +2105,15 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
21052105 // Handle `self` specially.
21062106 if index == 0 && has_self {
21072107 let self_lifetime = self . find_lifetime_for_self ( ty) ;
2108- if let Set1 :: One ( lifetime ) = self_lifetime {
2108+ elision_lifetime = match self_lifetime {
21092109 // We found `self` elision.
2110- elision_lifetime = Elision :: Self_ ( lifetime) ;
2111- } else {
2110+ Set1 :: One ( lifetime) => Elision :: Self_ ( lifetime) ,
2111+ // `self` itself had ambiguous lifetimes, e.g.
2112+ // &Box<&Self>
2113+ Set1 :: Many => Elision :: None ,
21122114 // We do not have `self` elision: disregard the `Elision::Param` that we may
21132115 // have found.
2114- elision_lifetime = Elision :: None ;
2116+ Set1 :: Empty => Elision :: None ,
21152117 }
21162118 }
21172119 debug ! ( "(resolving function / closure) recorded parameter" ) ;
@@ -2135,6 +2137,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
21352137 r : & ' r Resolver < ' a , ' tcx > ,
21362138 impl_self : Option < Res > ,
21372139 lifetime : Set1 < LifetimeRes > ,
2140+ self_found : bool ,
21382141 }
21392142
21402143 impl SelfVisitor < ' _ , ' _ , ' _ > {
@@ -2158,9 +2161,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
21582161 impl < ' a > Visitor < ' a > for SelfVisitor < ' _ , ' _ , ' _ > {
21592162 fn visit_ty ( & mut self , ty : & ' a Ty ) {
21602163 trace ! ( "SelfVisitor considering ty={:?}" , ty) ;
2161- if let TyKind :: Ref ( lt, ref mt) = ty. kind
2162- && self . is_self_ty ( & mt. ty )
2163- {
2164+ if self . is_self_ty ( ty) {
2165+ trace ! ( "SelfVisitor found Self" ) ;
2166+ self . self_found = true ;
2167+ }
2168+ if let TyKind :: Ref ( lt, _) = ty. kind {
21642169 let lt_id = if let Some ( lt) = lt {
21652170 lt. id
21662171 } else {
@@ -2201,10 +2206,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
22012206 Res :: Def ( DefKind :: Struct | DefKind :: Union | DefKind :: Enum , _, ) | Res :: PrimTy ( _)
22022207 )
22032208 } ) ;
2204- let mut visitor = SelfVisitor { r : self . r , impl_self, lifetime : Set1 :: Empty } ;
2209+ let mut visitor =
2210+ SelfVisitor { r : self . r , impl_self, lifetime : Set1 :: Empty , self_found : false } ;
22052211 visitor. visit_ty ( ty) ;
2206- trace ! ( "SelfVisitor found={:?}" , visitor. lifetime) ;
2207- visitor. lifetime
2212+ trace ! ( "SelfVisitor found={:?}, self_found={:?} " , visitor. lifetime, visitor . self_found ) ;
2213+ if visitor. self_found { visitor . lifetime } else { Set1 :: Empty }
22082214 }
22092215
22102216 /// Searches the current set of local scopes for labels. Returns the `NodeId` of the resolved
0 commit comments