@@ -2105,13 +2105,15 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2105
2105
// Handle `self` specially.
2106
2106
if index == 0 && has_self {
2107
2107
let self_lifetime = self . find_lifetime_for_self ( ty) ;
2108
- if let Set1 :: One ( lifetime ) = self_lifetime {
2108
+ elision_lifetime = match self_lifetime {
2109
2109
// 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 ,
2112
2114
// We do not have `self` elision: disregard the `Elision::Param` that we may
2113
2115
// have found.
2114
- elision_lifetime = Elision :: None ;
2116
+ Set1 :: Empty => Elision :: None ,
2115
2117
}
2116
2118
}
2117
2119
debug ! ( "(resolving function / closure) recorded parameter" ) ;
@@ -2135,6 +2137,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2135
2137
r : & ' r Resolver < ' a , ' tcx > ,
2136
2138
impl_self : Option < Res > ,
2137
2139
lifetime : Set1 < LifetimeRes > ,
2140
+ self_found : bool ,
2138
2141
}
2139
2142
2140
2143
impl SelfVisitor < ' _ , ' _ , ' _ > {
@@ -2158,9 +2161,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2158
2161
impl < ' a > Visitor < ' a > for SelfVisitor < ' _ , ' _ , ' _ > {
2159
2162
fn visit_ty ( & mut self , ty : & ' a Ty ) {
2160
2163
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 {
2164
2169
let lt_id = if let Some ( lt) = lt {
2165
2170
lt. id
2166
2171
} else {
@@ -2201,10 +2206,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2201
2206
Res :: Def ( DefKind :: Struct | DefKind :: Union | DefKind :: Enum , _, ) | Res :: PrimTy ( _)
2202
2207
)
2203
2208
} ) ;
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 } ;
2205
2211
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 }
2208
2214
}
2209
2215
2210
2216
/// Searches the current set of local scopes for labels. Returns the `NodeId` of the resolved
0 commit comments