@@ -27,13 +27,13 @@ macro_rules! lint_callback { ($cx:expr, $f:ident, $($args:expr),*) => ({
27
27
28
28
/// Implements the AST traversal for early lint passes. `T` provides the
29
29
/// `check_*` methods.
30
- pub struct EarlyContextAndPass < ' a , ' b , T : EarlyLintPass > {
31
- context : EarlyContext < ' a > ,
32
- tcx : Option < TyCtxt < ' b > > ,
30
+ pub struct EarlyContextAndPass < ' ecx , ' tcx , T : EarlyLintPass > {
31
+ context : EarlyContext < ' ecx > ,
32
+ tcx : Option < TyCtxt < ' tcx > > ,
33
33
pass : T ,
34
34
}
35
35
36
- impl < ' a , ' b , T : EarlyLintPass > EarlyContextAndPass < ' a , ' b , T > {
36
+ impl < ' ecx , ' tcx , T : EarlyLintPass > EarlyContextAndPass < ' ecx , ' tcx , T > {
37
37
// This always-inlined function is for the hot call site.
38
38
#[ inline( always) ]
39
39
#[ allow( rustc:: diagnostic_outside_of_impl) ]
@@ -54,7 +54,7 @@ impl<'a, 'b, T: EarlyLintPass> EarlyContextAndPass<'a, 'b, T> {
54
54
/// Merge the lints specified by any lint attributes into the
55
55
/// current lint context, call the provided function, then reset the
56
56
/// lints in effect to their previous state.
57
- fn with_lint_attrs < F > ( & mut self , id : ast:: NodeId , attrs : & ' a [ ast:: Attribute ] , f : F )
57
+ fn with_lint_attrs < F > ( & mut self , id : ast:: NodeId , attrs : & ' _ [ ast:: Attribute ] , f : F )
58
58
where
59
59
F : FnOnce ( & mut Self ) ,
60
60
{
@@ -72,65 +72,67 @@ impl<'a, 'b, T: EarlyLintPass> EarlyContextAndPass<'a, 'b, T> {
72
72
}
73
73
}
74
74
75
- impl < ' a , ' b , T : EarlyLintPass > ast_visit:: Visitor < ' a > for EarlyContextAndPass < ' a , ' b , T > {
76
- fn visit_coroutine_kind ( & mut self , coroutine_kind : & ' a ast:: CoroutineKind ) -> Self :: Result {
75
+ impl < ' ast , ' ecx , ' tcx , T : EarlyLintPass > ast_visit:: Visitor < ' ast >
76
+ for EarlyContextAndPass < ' ecx , ' tcx , T >
77
+ {
78
+ fn visit_coroutine_kind ( & mut self , coroutine_kind : & ' ast ast:: CoroutineKind ) -> Self :: Result {
77
79
self . check_id ( coroutine_kind. closure_id ( ) ) ;
78
80
}
79
81
80
- fn visit_param ( & mut self , param : & ' a ast:: Param ) {
82
+ fn visit_param ( & mut self , param : & ' ast ast:: Param ) {
81
83
self . with_lint_attrs ( param. id , & param. attrs , |cx| {
82
84
lint_callback ! ( cx, check_param, param) ;
83
85
ast_visit:: walk_param ( cx, param) ;
84
86
} ) ;
85
87
}
86
88
87
- fn visit_item ( & mut self , it : & ' a ast:: Item ) {
89
+ fn visit_item ( & mut self , it : & ' ast ast:: Item ) {
88
90
self . with_lint_attrs ( it. id , & it. attrs , |cx| {
89
91
lint_callback ! ( cx, check_item, it) ;
90
92
ast_visit:: walk_item ( cx, it) ;
91
93
lint_callback ! ( cx, check_item_post, it) ;
92
94
} )
93
95
}
94
96
95
- fn visit_foreign_item ( & mut self , it : & ' a ast:: ForeignItem ) {
97
+ fn visit_foreign_item ( & mut self , it : & ' ast ast:: ForeignItem ) {
96
98
self . with_lint_attrs ( it. id , & it. attrs , |cx| {
97
99
ast_visit:: walk_item ( cx, it) ;
98
100
} )
99
101
}
100
102
101
- fn visit_pat ( & mut self , p : & ' a ast:: Pat ) {
103
+ fn visit_pat ( & mut self , p : & ' ast ast:: Pat ) {
102
104
lint_callback ! ( self , check_pat, p) ;
103
105
self . check_id ( p. id ) ;
104
106
ast_visit:: walk_pat ( self , p) ;
105
107
lint_callback ! ( self , check_pat_post, p) ;
106
108
}
107
109
108
- fn visit_pat_field ( & mut self , field : & ' a ast:: PatField ) {
110
+ fn visit_pat_field ( & mut self , field : & ' ast ast:: PatField ) {
109
111
self . with_lint_attrs ( field. id , & field. attrs , |cx| {
110
112
ast_visit:: walk_pat_field ( cx, field) ;
111
113
} ) ;
112
114
}
113
115
114
- fn visit_anon_const ( & mut self , c : & ' a ast:: AnonConst ) {
116
+ fn visit_anon_const ( & mut self , c : & ' ast ast:: AnonConst ) {
115
117
self . check_id ( c. id ) ;
116
118
ast_visit:: walk_anon_const ( self , c) ;
117
119
}
118
120
119
- fn visit_expr ( & mut self , e : & ' a ast:: Expr ) {
121
+ fn visit_expr ( & mut self , e : & ' ast ast:: Expr ) {
120
122
self . with_lint_attrs ( e. id , & e. attrs , |cx| {
121
123
lint_callback ! ( cx, check_expr, e) ;
122
124
ast_visit:: walk_expr ( cx, e) ;
123
125
lint_callback ! ( cx, check_expr_post, e) ;
124
126
} )
125
127
}
126
128
127
- fn visit_expr_field ( & mut self , f : & ' a ast:: ExprField ) {
129
+ fn visit_expr_field ( & mut self , f : & ' ast ast:: ExprField ) {
128
130
self . with_lint_attrs ( f. id , & f. attrs , |cx| {
129
131
ast_visit:: walk_expr_field ( cx, f) ;
130
132
} )
131
133
}
132
134
133
- fn visit_stmt ( & mut self , s : & ' a ast:: Stmt ) {
135
+ fn visit_stmt ( & mut self , s : & ' ast ast:: Stmt ) {
134
136
// Add the statement's lint attributes to our
135
137
// current state when checking the statement itself.
136
138
// This allows us to handle attributes like
@@ -150,33 +152,33 @@ impl<'a, 'b, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a
150
152
ast_visit:: walk_stmt ( self , s) ;
151
153
}
152
154
153
- fn visit_fn ( & mut self , fk : ast_visit:: FnKind < ' a > , span : Span , id : ast:: NodeId ) {
155
+ fn visit_fn ( & mut self , fk : ast_visit:: FnKind < ' ast > , span : Span , id : ast:: NodeId ) {
154
156
lint_callback ! ( self , check_fn, fk, span, id) ;
155
157
self . check_id ( id) ;
156
158
ast_visit:: walk_fn ( self , fk) ;
157
159
}
158
160
159
- fn visit_variant_data ( & mut self , s : & ' a ast:: VariantData ) {
161
+ fn visit_variant_data ( & mut self , s : & ' ast ast:: VariantData ) {
160
162
if let Some ( ctor_node_id) = s. ctor_node_id ( ) {
161
163
self . check_id ( ctor_node_id) ;
162
164
}
163
165
ast_visit:: walk_struct_def ( self , s) ;
164
166
}
165
167
166
- fn visit_field_def ( & mut self , s : & ' a ast:: FieldDef ) {
168
+ fn visit_field_def ( & mut self , s : & ' ast ast:: FieldDef ) {
167
169
self . with_lint_attrs ( s. id , & s. attrs , |cx| {
168
170
ast_visit:: walk_field_def ( cx, s) ;
169
171
} )
170
172
}
171
173
172
- fn visit_variant ( & mut self , v : & ' a ast:: Variant ) {
174
+ fn visit_variant ( & mut self , v : & ' ast ast:: Variant ) {
173
175
self . with_lint_attrs ( v. id , & v. attrs , |cx| {
174
176
lint_callback ! ( cx, check_variant, v) ;
175
177
ast_visit:: walk_variant ( cx, v) ;
176
178
} )
177
179
}
178
180
179
- fn visit_ty ( & mut self , t : & ' a ast:: Ty ) {
181
+ fn visit_ty ( & mut self , t : & ' ast ast:: Ty ) {
180
182
lint_callback ! ( self , check_ty, t) ;
181
183
self . check_id ( t. id ) ;
182
184
ast_visit:: walk_ty ( self , t) ;
@@ -186,55 +188,55 @@ impl<'a, 'b, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a
186
188
lint_callback ! ( self , check_ident, ident) ;
187
189
}
188
190
189
- fn visit_local ( & mut self , l : & ' a ast:: Local ) {
191
+ fn visit_local ( & mut self , l : & ' ast ast:: Local ) {
190
192
self . with_lint_attrs ( l. id , & l. attrs , |cx| {
191
193
lint_callback ! ( cx, check_local, l) ;
192
194
ast_visit:: walk_local ( cx, l) ;
193
195
} )
194
196
}
195
197
196
- fn visit_block ( & mut self , b : & ' a ast:: Block ) {
198
+ fn visit_block ( & mut self , b : & ' ast ast:: Block ) {
197
199
lint_callback ! ( self , check_block, b) ;
198
200
self . check_id ( b. id ) ;
199
201
ast_visit:: walk_block ( self , b) ;
200
202
}
201
203
202
- fn visit_arm ( & mut self , a : & ' a ast:: Arm ) {
204
+ fn visit_arm ( & mut self , a : & ' ast ast:: Arm ) {
203
205
self . with_lint_attrs ( a. id , & a. attrs , |cx| {
204
206
lint_callback ! ( cx, check_arm, a) ;
205
207
ast_visit:: walk_arm ( cx, a) ;
206
208
} )
207
209
}
208
210
209
- fn visit_generic_arg ( & mut self , arg : & ' a ast:: GenericArg ) {
211
+ fn visit_generic_arg ( & mut self , arg : & ' ast ast:: GenericArg ) {
210
212
lint_callback ! ( self , check_generic_arg, arg) ;
211
213
ast_visit:: walk_generic_arg ( self , arg) ;
212
214
}
213
215
214
- fn visit_generic_param ( & mut self , param : & ' a ast:: GenericParam ) {
216
+ fn visit_generic_param ( & mut self , param : & ' ast ast:: GenericParam ) {
215
217
self . with_lint_attrs ( param. id , & param. attrs , |cx| {
216
218
lint_callback ! ( cx, check_generic_param, param) ;
217
219
ast_visit:: walk_generic_param ( cx, param) ;
218
220
} ) ;
219
221
}
220
222
221
- fn visit_generics ( & mut self , g : & ' a ast:: Generics ) {
223
+ fn visit_generics ( & mut self , g : & ' ast ast:: Generics ) {
222
224
lint_callback ! ( self , check_generics, g) ;
223
225
ast_visit:: walk_generics ( self , g) ;
224
226
}
225
227
226
- fn visit_where_predicate ( & mut self , p : & ' a ast:: WherePredicate ) {
228
+ fn visit_where_predicate ( & mut self , p : & ' ast ast:: WherePredicate ) {
227
229
lint_callback ! ( self , enter_where_predicate, p) ;
228
230
ast_visit:: walk_where_predicate ( self , p) ;
229
231
lint_callback ! ( self , exit_where_predicate, p) ;
230
232
}
231
233
232
- fn visit_poly_trait_ref ( & mut self , t : & ' a ast:: PolyTraitRef ) {
234
+ fn visit_poly_trait_ref ( & mut self , t : & ' ast ast:: PolyTraitRef ) {
233
235
lint_callback ! ( self , check_poly_trait_ref, t) ;
234
236
ast_visit:: walk_poly_trait_ref ( self , t) ;
235
237
}
236
238
237
- fn visit_assoc_item ( & mut self , item : & ' a ast:: AssocItem , ctxt : ast_visit:: AssocCtxt ) {
239
+ fn visit_assoc_item ( & mut self , item : & ' ast ast:: AssocItem , ctxt : ast_visit:: AssocCtxt ) {
238
240
self . with_lint_attrs ( item. id , & item. attrs , |cx| {
239
241
match ctxt {
240
242
ast_visit:: AssocCtxt :: Trait => {
@@ -248,32 +250,32 @@ impl<'a, 'b, T: EarlyLintPass> ast_visit::Visitor<'a> for EarlyContextAndPass<'a
248
250
} ) ;
249
251
}
250
252
251
- fn visit_lifetime ( & mut self , lt : & ' a ast:: Lifetime , _: ast_visit:: LifetimeCtxt ) {
253
+ fn visit_lifetime ( & mut self , lt : & ' ast ast:: Lifetime , _: ast_visit:: LifetimeCtxt ) {
252
254
self . check_id ( lt. id ) ;
253
255
ast_visit:: walk_lifetime ( self , lt) ;
254
256
}
255
257
256
- fn visit_path ( & mut self , p : & ' a ast:: Path , id : ast:: NodeId ) {
258
+ fn visit_path ( & mut self , p : & ' ast ast:: Path , id : ast:: NodeId ) {
257
259
self . check_id ( id) ;
258
260
ast_visit:: walk_path ( self , p) ;
259
261
}
260
262
261
- fn visit_path_segment ( & mut self , s : & ' a ast:: PathSegment ) {
263
+ fn visit_path_segment ( & mut self , s : & ' ast ast:: PathSegment ) {
262
264
self . check_id ( s. id ) ;
263
265
ast_visit:: walk_path_segment ( self , s) ;
264
266
}
265
267
266
- fn visit_attribute ( & mut self , attr : & ' a ast:: Attribute ) {
268
+ fn visit_attribute ( & mut self , attr : & ' ast ast:: Attribute ) {
267
269
lint_callback ! ( self , check_attribute, attr) ;
268
270
ast_visit:: walk_attribute ( self , attr) ;
269
271
}
270
272
271
- fn visit_mac_def ( & mut self , mac : & ' a ast:: MacroDef , id : ast:: NodeId ) {
273
+ fn visit_mac_def ( & mut self , mac : & ' ast ast:: MacroDef , id : ast:: NodeId ) {
272
274
lint_callback ! ( self , check_mac_def, mac) ;
273
275
self . check_id ( id) ;
274
276
}
275
277
276
- fn visit_mac_call ( & mut self , mac : & ' a ast:: MacCall ) {
278
+ fn visit_mac_call ( & mut self , mac : & ' ast ast:: MacCall ) {
277
279
lint_callback ! ( self , check_mac, mac) ;
278
280
ast_visit:: walk_mac ( self , mac) ;
279
281
}
@@ -315,28 +317,18 @@ crate::early_lint_methods!(impl_early_lint_pass, []);
315
317
/// This trait generalizes over those nodes.
316
318
pub trait EarlyCheckNode < ' a > : Copy {
317
319
fn id ( self ) -> ast:: NodeId ;
318
- fn attrs < ' b > ( self ) -> & ' b [ ast:: Attribute ]
319
- where
320
- ' a : ' b ;
321
- fn check < ' b , ' c , T : EarlyLintPass > ( self , cx : & mut EarlyContextAndPass < ' b , ' c , T > )
322
- where
323
- ' a : ' b ;
320
+ fn attrs ( self ) -> & ' a [ ast:: Attribute ] ;
321
+ fn check < ' ecx , ' tcx , T : EarlyLintPass > ( self , cx : & mut EarlyContextAndPass < ' ecx , ' tcx , T > ) ;
324
322
}
325
323
326
324
impl < ' a > EarlyCheckNode < ' a > for ( & ' a ast:: Crate , & ' a [ ast:: Attribute ] ) {
327
325
fn id ( self ) -> ast:: NodeId {
328
326
ast:: CRATE_NODE_ID
329
327
}
330
- fn attrs < ' b > ( self ) -> & ' b [ ast:: Attribute ]
331
- where
332
- ' a : ' b ,
333
- {
328
+ fn attrs ( self ) -> & ' a [ ast:: Attribute ] {
334
329
self . 1
335
330
}
336
- fn check < ' b , ' c , T : EarlyLintPass > ( self , cx : & mut EarlyContextAndPass < ' b , ' c , T > )
337
- where
338
- ' a : ' b ,
339
- {
331
+ fn check < ' ecx , ' tcx , T : EarlyLintPass > ( self , cx : & mut EarlyContextAndPass < ' ecx , ' tcx , T > ) {
340
332
lint_callback ! ( cx, check_crate, self . 0 ) ;
341
333
ast_visit:: walk_crate ( cx, self . 0 ) ;
342
334
lint_callback ! ( cx, check_crate_post, self . 0 ) ;
@@ -347,16 +339,10 @@ impl<'a> EarlyCheckNode<'a> for (ast::NodeId, &'a [ast::Attribute], &'a [P<ast::
347
339
fn id ( self ) -> ast:: NodeId {
348
340
self . 0
349
341
}
350
- fn attrs < ' b > ( self ) -> & ' b [ ast:: Attribute ]
351
- where
352
- ' a : ' b ,
353
- {
342
+ fn attrs ( self ) -> & ' a [ ast:: Attribute ] {
354
343
self . 1
355
344
}
356
- fn check < ' b , ' c , T : EarlyLintPass > ( self , cx : & mut EarlyContextAndPass < ' b , ' c , T > )
357
- where
358
- ' a : ' b ,
359
- {
345
+ fn check < ' ecx , ' tcx , T : EarlyLintPass > ( self , cx : & mut EarlyContextAndPass < ' ecx , ' tcx , T > ) {
360
346
walk_list ! ( cx, visit_attribute, self . 1 ) ;
361
347
walk_list ! ( cx, visit_item, self . 2 ) ;
362
348
}
0 commit comments