@@ -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 , ParamName , 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;
@@ -180,7 +180,7 @@ fn check_fn_inner<'tcx>(
180
180
_ => None ,
181
181
} ) ;
182
182
for bound in lifetimes {
183
- if bound. name != LifetimeName :: Static && !bound. is_elided ( ) {
183
+ if ! bound. is_static ( ) && !bound. is_elided ( ) {
184
184
return ;
185
185
}
186
186
}
@@ -414,17 +414,13 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> {
414
414
415
415
fn record ( & mut self , lifetime : & Option < Lifetime > ) {
416
416
if let Some ( ref lt) = * lifetime {
417
- if lt. name == LifetimeName :: Static {
417
+ if lt. is_static ( ) {
418
418
self . lts . push ( RefLt :: Static ) ;
419
- } else if let LifetimeName :: Param ( _ , ParamName :: Fresh ) = lt. name {
419
+ } else if lt. is_anonymous ( ) {
420
420
// Fresh lifetimes generated should be ignored.
421
421
self . lts . push ( RefLt :: Unnamed ) ;
422
- } else if lt. is_elided ( ) {
423
- self . lts . push ( RefLt :: Unnamed ) ;
424
- } else if let LifetimeName :: Param ( def_id, _) = lt. name {
422
+ } else if let LifetimeName :: Param ( def_id) = lt. res {
425
423
self . lts . push ( RefLt :: Named ( def_id) ) ;
426
- } else {
427
- self . lts . push ( RefLt :: Unnamed ) ;
428
424
}
429
425
} else {
430
426
self . lts . push ( RefLt :: Unnamed ) ;
@@ -472,7 +468,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
472
468
walk_item ( self , item) ;
473
469
self . lts . truncate ( len) ;
474
470
self . lts . extend ( bounds. iter ( ) . filter_map ( |bound| match bound {
475
- GenericArg :: Lifetime ( l) => Some ( if let LifetimeName :: Param ( def_id, _ ) = l. name {
471
+ GenericArg :: Lifetime ( l) => Some ( if let LifetimeName :: Param ( def_id) = l. res {
476
472
RefLt :: Named ( def_id)
477
473
} else {
478
474
RefLt :: Unnamed
@@ -498,10 +494,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
498
494
}
499
495
500
496
fn visit_generic_arg ( & mut self , generic_arg : & ' tcx GenericArg < ' tcx > ) {
501
- if let GenericArg :: Lifetime ( l) = generic_arg
502
- && let LifetimeName :: Param ( def_id, _) = l. name
503
- {
504
- self . lifetime_generic_arg_spans . entry ( def_id) . or_insert ( l. span ) ;
497
+ if let GenericArg :: Lifetime ( l) = generic_arg && let LifetimeName :: Param ( def_id) = l. res {
498
+ self . lifetime_generic_arg_spans . entry ( def_id) . or_insert ( l. ident . span ) ;
505
499
}
506
500
walk_generic_arg ( self , generic_arg) ;
507
501
}
@@ -570,7 +564,7 @@ where
570
564
571
565
// for lifetimes as parameters of generics
572
566
fn visit_lifetime ( & mut self , lifetime : & ' tcx Lifetime ) {
573
- self . map . remove ( & lifetime. name . ident ( ) . name ) ;
567
+ self . map . remove ( & lifetime. ident . name ) ;
574
568
}
575
569
576
570
fn visit_generic_param ( & mut self , param : & ' tcx GenericParam < ' _ > ) {
@@ -594,7 +588,9 @@ fn report_extra_lifetimes<'tcx>(cx: &LateContext<'tcx>, func: &'tcx FnDecl<'_>,
594
588
. params
595
589
. iter ( )
596
590
. filter_map ( |par| match par. kind {
597
- GenericParamKind :: Lifetime { .. } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
591
+ GenericParamKind :: Lifetime {
592
+ kind : LifetimeParamKind :: Explicit ,
593
+ } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
598
594
_ => None ,
599
595
} )
600
596
. collect ( ) ;
@@ -619,7 +615,9 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
619
615
. params
620
616
. iter ( )
621
617
. filter_map ( |par| match par. kind {
622
- GenericParamKind :: Lifetime { .. } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
618
+ GenericParamKind :: Lifetime {
619
+ kind : LifetimeParamKind :: Explicit ,
620
+ } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
623
621
_ => None ,
624
622
} )
625
623
. collect ( ) ;
@@ -646,7 +644,7 @@ struct BodyLifetimeChecker {
646
644
impl < ' tcx > Visitor < ' tcx > for BodyLifetimeChecker {
647
645
// for lifetimes as parameters of generics
648
646
fn visit_lifetime ( & mut self , lifetime : & ' tcx Lifetime ) {
649
- if lifetime. name . ident ( ) . name != kw :: UnderscoreLifetime && lifetime. name . ident ( ) . name != kw:: StaticLifetime {
647
+ if ! lifetime. is_anonymous ( ) && lifetime. ident . name != kw:: StaticLifetime {
650
648
self . lifetimes_used_in_body = true ;
651
649
}
652
650
}
0 commit comments