@@ -10,8 +10,8 @@ use rustc_hir::lang_items;
10
10
use rustc_hir:: FnRetTy :: Return ;
11
11
use rustc_hir:: {
12
12
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 ,
15
15
} ;
16
16
use rustc_lint:: { LateContext , LateLintPass } ;
17
17
use rustc_middle:: hir:: nested_filter as middle_nested_filter;
@@ -595,7 +595,9 @@ fn report_extra_lifetimes<'tcx>(cx: &LateContext<'tcx>, func: &'tcx FnDecl<'_>,
595
595
. params
596
596
. iter ( )
597
597
. 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 ) ) ,
599
601
_ => None ,
600
602
} )
601
603
. collect ( ) ;
@@ -620,7 +622,9 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
620
622
. params
621
623
. iter ( )
622
624
. 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 ) ) ,
624
628
_ => None ,
625
629
} )
626
630
. collect ( ) ;
@@ -647,7 +651,7 @@ struct BodyLifetimeChecker {
647
651
impl < ' tcx > Visitor < ' tcx > for BodyLifetimeChecker {
648
652
// for lifetimes as parameters of generics
649
653
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 {
651
655
self . lifetimes_used_in_body = true ;
652
656
}
653
657
}
0 commit comments