@@ -2090,13 +2090,15 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2090
2090
// Handle `self` specially.
2091
2091
if index == 0 && has_self {
2092
2092
let self_lifetime = self . find_lifetime_for_self ( ty) ;
2093
- if let Set1 :: One ( lifetime ) = self_lifetime {
2093
+ elision_lifetime = match self_lifetime {
2094
2094
// We found `self` elision.
2095
- elision_lifetime = Elision :: Self_ ( lifetime) ;
2096
- } else {
2095
+ Set1 :: One ( lifetime) => Elision :: Self_ ( lifetime) ,
2096
+ // `self` itself had ambiguous lifetimes, e.g.
2097
+ // &Box<&Self>
2098
+ Set1 :: Many => Elision :: Err ,
2097
2099
// We do not have `self` elision: disregard the `Elision::Param` that we may
2098
2100
// have found.
2099
- elision_lifetime = Elision :: None ;
2101
+ Set1 :: Empty => Elision :: None ,
2100
2102
}
2101
2103
}
2102
2104
debug ! ( "(resolving function / closure) recorded parameter" ) ;
@@ -2120,6 +2122,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2120
2122
r : & ' r Resolver < ' a , ' tcx > ,
2121
2123
impl_self : Option < Res > ,
2122
2124
lifetime : Set1 < LifetimeRes > ,
2125
+ self_found : bool ,
2123
2126
}
2124
2127
2125
2128
impl SelfVisitor < ' _ , ' _ , ' _ > {
@@ -2143,9 +2146,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2143
2146
impl < ' a > Visitor < ' a > for SelfVisitor < ' _ , ' _ , ' _ > {
2144
2147
fn visit_ty ( & mut self , ty : & ' a Ty ) {
2145
2148
trace ! ( "SelfVisitor considering ty={:?}" , ty) ;
2146
- if let TyKind :: Ref ( lt, ref mt) = ty. kind
2147
- && self . is_self_ty ( & mt. ty )
2148
- {
2149
+ if self . is_self_ty ( ty) {
2150
+ trace ! ( "SelfVisitor found Self" ) ;
2151
+ self . self_found = true ;
2152
+ }
2153
+ if let TyKind :: Ref ( lt, _) = ty. kind {
2149
2154
let lt_id = if let Some ( lt) = lt {
2150
2155
lt. id
2151
2156
} else {
@@ -2186,10 +2191,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
2186
2191
Res :: Def ( DefKind :: Struct | DefKind :: Union | DefKind :: Enum , _, ) | Res :: PrimTy ( _)
2187
2192
)
2188
2193
} ) ;
2189
- let mut visitor = SelfVisitor { r : self . r , impl_self, lifetime : Set1 :: Empty } ;
2194
+ let mut visitor =
2195
+ SelfVisitor { r : self . r , impl_self, lifetime : Set1 :: Empty , self_found : false } ;
2190
2196
visitor. visit_ty ( ty) ;
2191
- trace ! ( "SelfVisitor found={:?}" , visitor. lifetime) ;
2192
- visitor. lifetime
2197
+ trace ! ( "SelfVisitor found={:?}, self_found={:?} " , visitor. lifetime, visitor . self_found ) ;
2198
+ if visitor. self_found { visitor . lifetime } else { Set1 :: Empty }
2193
2199
}
2194
2200
2195
2201
/// Searches the current set of local scopes for labels. Returns the `NodeId` of the resolved
0 commit comments