@@ -10,8 +10,8 @@ use rustc_hir::lang_items;
1010use rustc_hir:: FnRetTy :: Return ;
1111use rustc_hir:: {
1212 BareFnTy , BodyId , FnDecl , GenericArg , GenericBound , GenericParam , GenericParamKind , Generics , Impl , ImplItem ,
13- ImplItemKind , Item , ItemKind , Lifetime , LifetimeName , PolyTraitRef , PredicateOrigin , TraitFn , TraitItem ,
14- TraitItemKind , Ty , TyKind , WherePredicate ,
13+ ImplItemKind , Item , ItemKind , Lifetime , LifetimeName , LifetimeParamKind , PolyTraitRef , PredicateOrigin , TraitFn ,
14+ TraitItem , TraitItemKind , Ty , TyKind , WherePredicate ,
1515} ;
1616use rustc_lint:: { LateContext , LateLintPass } ;
1717use rustc_middle:: hir:: nested_filter as middle_nested_filter;
@@ -595,7 +595,9 @@ fn report_extra_lifetimes<'tcx>(cx: &LateContext<'tcx>, func: &'tcx FnDecl<'_>,
595595 . params
596596 . iter ( )
597597 . filter_map ( |par| match par. kind {
598- GenericParamKind :: Lifetime { .. } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
598+ GenericParamKind :: Lifetime {
599+ kind : LifetimeParamKind :: Explicit ,
600+ } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
599601 _ => None ,
600602 } )
601603 . collect ( ) ;
@@ -620,7 +622,9 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
620622 . params
621623 . iter ( )
622624 . filter_map ( |par| match par. kind {
623- GenericParamKind :: Lifetime { .. } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
625+ GenericParamKind :: Lifetime {
626+ kind : LifetimeParamKind :: Explicit ,
627+ } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
624628 _ => None ,
625629 } )
626630 . collect ( ) ;
@@ -647,7 +651,7 @@ struct BodyLifetimeChecker {
647651impl < ' tcx > Visitor < ' tcx > for BodyLifetimeChecker {
648652 // for lifetimes as parameters of generics
649653 fn visit_lifetime ( & mut self , lifetime : & ' tcx Lifetime ) {
650- if lifetime. ident . name != kw :: UnderscoreLifetime && lifetime. ident . name != kw:: StaticLifetime {
654+ if ! lifetime. is_anonymous ( ) && lifetime. ident . name != kw:: StaticLifetime {
651655 self . lifetimes_used_in_body = true ;
652656 }
653657 }
0 commit comments