@@ -223,30 +223,32 @@ struct UseSelfVisitor<'a, 'tcx> {
223223
224224impl < ' a , ' tcx > Visitor < ' tcx > for UseSelfVisitor < ' a , ' tcx > {
225225 fn visit_path ( & mut self , path : & ' tcx Path , _id : HirId ) {
226- if path. segments . len ( ) >= 2 {
227- let last_but_one = & path. segments [ path. segments . len ( ) - 2 ] ;
228- if last_but_one. ident . name != kw:: SelfUpper {
229- let enum_def_id = match path. res {
230- Res :: Def ( DefKind :: Variant , variant_def_id) => self . cx . tcx . parent ( variant_def_id) ,
231- Res :: Def ( DefKind :: Ctor ( def:: CtorOf :: Variant , _) , ctor_def_id) => {
232- let variant_def_id = self . cx . tcx . parent ( ctor_def_id) ;
233- variant_def_id. and_then ( |def_id| self . cx . tcx . parent ( def_id) )
234- } ,
235- _ => None ,
236- } ;
226+ if !path. segments . iter ( ) . any ( |p| p. ident . span . is_dummy ( ) ) {
227+ if path. segments . len ( ) >= 2 {
228+ let last_but_one = & path. segments [ path. segments . len ( ) - 2 ] ;
229+ if last_but_one. ident . name != kw:: SelfUpper {
230+ let enum_def_id = match path. res {
231+ Res :: Def ( DefKind :: Variant , variant_def_id) => self . cx . tcx . parent ( variant_def_id) ,
232+ Res :: Def ( DefKind :: Ctor ( def:: CtorOf :: Variant , _) , ctor_def_id) => {
233+ let variant_def_id = self . cx . tcx . parent ( ctor_def_id) ;
234+ variant_def_id. and_then ( |def_id| self . cx . tcx . parent ( def_id) )
235+ } ,
236+ _ => None ,
237+ } ;
237238
238- if self . item_path . res . opt_def_id ( ) == enum_def_id {
239- span_use_self_lint ( self . cx , path, Some ( last_but_one) ) ;
239+ if self . item_path . res . opt_def_id ( ) == enum_def_id {
240+ span_use_self_lint ( self . cx , path, Some ( last_but_one) ) ;
241+ }
240242 }
241243 }
242- }
243244
244- if path. segments . last ( ) . expect ( SEGMENTS_MSG ) . ident . name != kw:: SelfUpper {
245- if self . item_path . res == path. res {
246- span_use_self_lint ( self . cx , path, None ) ;
247- } else if let Res :: Def ( DefKind :: Ctor ( def:: CtorOf :: Struct , _) , ctor_def_id) = path. res {
248- if self . item_path . res . opt_def_id ( ) == self . cx . tcx . parent ( ctor_def_id) {
245+ if path. segments . last ( ) . expect ( SEGMENTS_MSG ) . ident . name != kw:: SelfUpper {
246+ if self . item_path . res == path. res {
249247 span_use_self_lint ( self . cx , path, None ) ;
248+ } else if let Res :: Def ( DefKind :: Ctor ( def:: CtorOf :: Struct , _) , ctor_def_id) = path. res {
249+ if self . item_path . res . opt_def_id ( ) == self . cx . tcx . parent ( ctor_def_id) {
250+ span_use_self_lint ( self . cx , path, None ) ;
251+ }
250252 }
251253 }
252254 }
0 commit comments