@@ -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 , 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 ,
1515} ;
1616use rustc_lint:: { LateContext , LateLintPass } ;
1717use rustc_middle:: hir:: nested_filter as middle_nested_filter;
@@ -180,7 +180,7 @@ fn check_fn_inner<'tcx>(
180180 _ => None ,
181181 } ) ;
182182 for bound in lifetimes {
183- if bound. name != LifetimeName :: Static && !bound. is_elided ( ) {
183+ if ! bound. is_static ( ) && !bound. is_elided ( ) {
184184 return ;
185185 }
186186 }
@@ -414,17 +414,13 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> {
414414
415415 fn record ( & mut self , lifetime : & Option < Lifetime > ) {
416416 if let Some ( ref lt) = * lifetime {
417- if lt. name == LifetimeName :: Static {
417+ if lt. is_static ( ) {
418418 self . lts . push ( RefLt :: Static ) ;
419- } else if let LifetimeName :: Param ( _ , ParamName :: Fresh ) = lt. name {
419+ } else if lt. is_anonymous ( ) {
420420 // Fresh lifetimes generated should be ignored.
421421 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 {
425423 self . lts . push ( RefLt :: Named ( def_id) ) ;
426- } else {
427- self . lts . push ( RefLt :: Unnamed ) ;
428424 }
429425 } else {
430426 self . lts . push ( RefLt :: Unnamed ) ;
@@ -472,7 +468,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
472468 walk_item ( self , item) ;
473469 self . lts . truncate ( len) ;
474470 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 {
476472 RefLt :: Named ( def_id)
477473 } else {
478474 RefLt :: Unnamed
@@ -498,10 +494,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
498494 }
499495
500496 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 ) ;
505499 }
506500 // Replace with `walk_generic_arg` if/when https://github.com/rust-lang/rust/pull/103692 lands.
507501 // walk_generic_arg(self, generic_arg);
@@ -577,7 +571,7 @@ where
577571
578572 // for lifetimes as parameters of generics
579573 fn visit_lifetime ( & mut self , lifetime : & ' tcx Lifetime ) {
580- self . map . remove ( & lifetime. name . ident ( ) . name ) ;
574+ self . map . remove ( & lifetime. ident . name ) ;
581575 }
582576
583577 fn visit_generic_param ( & mut self , param : & ' tcx GenericParam < ' _ > ) {
@@ -601,7 +595,9 @@ fn report_extra_lifetimes<'tcx>(cx: &LateContext<'tcx>, func: &'tcx FnDecl<'_>,
601595 . params
602596 . iter ( )
603597 . filter_map ( |par| match par. kind {
604- GenericParamKind :: Lifetime { .. } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
598+ GenericParamKind :: Lifetime {
599+ kind : LifetimeParamKind :: Explicit ,
600+ } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
605601 _ => None ,
606602 } )
607603 . collect ( ) ;
@@ -626,7 +622,9 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
626622 . params
627623 . iter ( )
628624 . filter_map ( |par| match par. kind {
629- GenericParamKind :: Lifetime { .. } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
625+ GenericParamKind :: Lifetime {
626+ kind : LifetimeParamKind :: Explicit ,
627+ } => Some ( ( par. name . ident ( ) . name , par. span ) ) ,
630628 _ => None ,
631629 } )
632630 . collect ( ) ;
@@ -653,7 +651,7 @@ struct BodyLifetimeChecker {
653651impl < ' tcx > Visitor < ' tcx > for BodyLifetimeChecker {
654652 // for lifetimes as parameters of generics
655653 fn visit_lifetime ( & mut self , lifetime : & ' tcx Lifetime ) {
656- if lifetime. name . ident ( ) . name != kw :: UnderscoreLifetime && lifetime. name . ident ( ) . name != kw:: StaticLifetime {
654+ if ! lifetime. is_anonymous ( ) && lifetime. ident . name != kw:: StaticLifetime {
657655 self . lifetimes_used_in_body = true ;
658656 }
659657 }
0 commit comments