@@ -59,7 +59,7 @@ impl LintPass for LifetimePass {
59
59
60
60
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for LifetimePass {
61
61
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 {
63
63
check_fn_inner ( cx, decl, Some ( id) , generics, item. span ) ;
64
64
}
65
65
}
@@ -101,32 +101,35 @@ fn check_fn_inner<'a, 'tcx>(
101
101
}
102
102
103
103
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) ;
123
127
}
124
- bounds_lts. push ( bound) ;
125
128
}
126
129
}
127
130
}
128
- }
129
- }
131
+ } ,
132
+ } ) ;
130
133
if could_use_elision ( cx, decl, body, & generics. params , bounds_lts) {
131
134
span_lint (
132
135
cx,
@@ -295,7 +298,7 @@ impl<'v, 't> RefVisitor<'v, 't> {
295
298
}
296
299
297
300
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 {
299
302
if !last_path_segment. parenthesized && last_path_segment. lifetimes . is_empty ( ) {
300
303
let hir_id = self . cx . tcx . hir . node_to_hir_id ( ty. id ) ;
301
304
match self . cx . tables . qpath_def ( qpath, hir_id) {
@@ -335,7 +338,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
335
338
TyImplTraitExistential ( exist_ty_id, _, _) => {
336
339
if let ItemExistential ( ref exist_ty) = self . cx . tcx . hir . expect_item ( exist_ty_id. id ) . node {
337
340
for bound in & exist_ty. bounds {
338
- if let RegionTyParamBound ( _) = * bound {
341
+ if let GenericBound :: Outlives ( _) = * bound {
339
342
self . record ( & None ) ;
340
343
}
341
344
}
@@ -377,7 +380,7 @@ fn has_where_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, where_clause: &
377
380
let allowed_lts = allowed_lts_from ( & pred. bound_generic_params ) ;
378
381
// now walk the bounds
379
382
for bound in pred. bounds . iter ( ) {
380
- walk_ty_param_bound ( & mut visitor, bound) ;
383
+ walk_param_bound ( & mut visitor, bound) ;
381
384
}
382
385
// and check that all lifetimes are allowed
383
386
match visitor. into_vec ( ) {
@@ -418,7 +421,7 @@ impl<'tcx> Visitor<'tcx> for LifetimeChecker {
418
421
// don't want to spuriously remove them
419
422
// `'b` in `'a: 'b` is useless unless used elsewhere in
420
423
// a non-lifetime bound
421
- if param. is_type_param ( ) {
424
+ if let GenericParamKind :: Type { .. } = param. kind {
422
425
walk_generic_param ( self , param)
423
426
}
424
427
}
0 commit comments