@@ -59,7 +59,7 @@ impl LintPass for LifetimePass {
5959
6060impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for LifetimePass {
6161 fn check_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx Item ) {
62- if let ItemFn ( ref decl, _, _ , _ , ref generics, id) = item. node {
62+ if let ItemFn ( ref decl, _, ref generics, id) = item. node {
6363 check_fn_inner ( cx, decl, Some ( id) , generics, item. span ) ;
6464 }
6565 }
@@ -101,32 +101,35 @@ fn check_fn_inner<'a, 'tcx>(
101101 }
102102
103103 let mut bounds_lts = Vec :: new ( ) ;
104- for typ in generics. ty_params ( ) {
105- for bound in & typ. bounds {
106- let mut visitor = RefVisitor :: new ( cx) ;
107- walk_ty_param_bound ( & mut visitor, bound) ;
108- if visitor. lts . iter ( ) . any ( |lt| matches ! ( lt, RefLt :: Named ( _) ) ) {
109- return ;
110- }
111- if let TraitTyParamBound ( ref trait_ref, _) = * bound {
112- let params = & trait_ref
113- . trait_ref
114- . path
115- . segments
116- . last ( )
117- . expect ( "a path must have at least one segment" )
118- . parameters ;
119- if let Some ( ref params) = * params {
120- for bound in & params. lifetimes {
121- if bound. name . name ( ) != "'static" && !bound. is_elided ( ) {
122- return ;
104+ generics. params . iter ( ) . for_each ( |param| match param. kind {
105+ GenericParamKind :: Lifetime { .. } => { } ,
106+ GenericParamKind :: Type { .. } => {
107+ for bound in & param. bounds {
108+ let mut visitor = RefVisitor :: new ( cx) ;
109+ walk_param_bound ( & mut visitor, bound) ;
110+ if visitor. lts . iter ( ) . any ( |lt| matches ! ( lt, RefLt :: Named ( _) ) ) {
111+ return ;
112+ }
113+ if let GenericBound :: Trait ( ref trait_ref, _) = * bound {
114+ let params = & trait_ref
115+ . trait_ref
116+ . path
117+ . segments
118+ . last ( )
119+ . expect ( "a path must have at least one segment" )
120+ . args ;
121+ if let Some ( ref params) = * params {
122+ for bound in & params. lifetimes {
123+ if bound. name . name ( ) != "'static" && !bound. is_elided ( ) {
124+ return ;
125+ }
126+ bounds_lts. push ( bound) ;
123127 }
124- bounds_lts. push ( bound) ;
125128 }
126129 }
127130 }
128- }
129- }
131+ } ,
132+ } ) ;
130133 if could_use_elision ( cx, decl, body, & generics. params , bounds_lts) {
131134 span_lint (
132135 cx,
@@ -295,7 +298,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
295298 }
296299
297300 fn collect_anonymous_lifetimes ( & mut self , qpath : & QPath , ty : & Ty ) {
298- if let Some ( ref last_path_segment) = last_path_segment ( qpath) . parameters {
301+ if let Some ( ref last_path_segment) = last_path_segment ( qpath) . args {
299302 if !last_path_segment. parenthesized && last_path_segment. lifetimes . is_empty ( ) {
300303 let hir_id = self . cx . tcx . hir . node_to_hir_id ( ty. id ) ;
301304 match self . cx . tables . qpath_def ( qpath, hir_id) {
@@ -335,7 +338,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
335338 TyImplTraitExistential ( exist_ty_id, _, _) => {
336339 if let ItemExistential ( ref exist_ty) = self . cx . tcx . hir . expect_item ( exist_ty_id. id ) . node {
337340 for bound in & exist_ty. bounds {
338- if let RegionTyParamBound ( _) = * bound {
341+ if let GenericBound :: Outlives ( _) = * bound {
339342 self . record ( & None ) ;
340343 }
341344 }
@@ -377,7 +380,7 @@ fn has_where_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, where_clause: &
377380 let allowed_lts = allowed_lts_from ( & pred. bound_generic_params ) ;
378381 // now walk the bounds
379382 for bound in pred. bounds . iter ( ) {
380- walk_ty_param_bound ( & mut visitor, bound) ;
383+ walk_param_bound ( & mut visitor, bound) ;
381384 }
382385 // and check that all lifetimes are allowed
383386 match visitor. into_vec ( ) {
@@ -418,7 +421,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
418421 // don't want to spuriously remove them
419422 // `'b` in `'a: 'b` is useless unless used elsewhere in
420423 // a non-lifetime bound
421- if param. is_type_param ( ) {
424+ if let GenericParamKind :: Type { .. } = param. kind {
422425 walk_generic_param ( self , param)
423426 }
424427 }
0 commit comments