@@ -9,49 +9,49 @@ use rustc_span::Span;
9
9
10
10
#[ macro_export]
11
11
macro_rules! late_lint_methods {
12
- ( $macro: path, $args: tt, [ $hir : tt ] ) => (
13
- $macro!( $args, [ $hir ] , [
14
- fn check_body( a: & $hir hir:: Body <$hir >) ;
15
- fn check_body_post( a: & $hir hir:: Body <$hir >) ;
12
+ ( $macro: path, $args: tt) => (
13
+ $macro!( $args, [
14
+ fn check_body( a: & ' tcx hir:: Body <' tcx >) ;
15
+ fn check_body_post( a: & ' tcx hir:: Body <' tcx >) ;
16
16
fn check_crate( ) ;
17
17
fn check_crate_post( ) ;
18
- fn check_mod( a: & $hir hir:: Mod <$hir >, b: hir:: HirId ) ;
19
- fn check_foreign_item( a: & $hir hir:: ForeignItem <$hir >) ;
20
- fn check_item( a: & $hir hir:: Item <$hir >) ;
21
- fn check_item_post( a: & $hir hir:: Item <$hir >) ;
22
- fn check_local( a: & $hir hir:: Local <$hir >) ;
23
- fn check_block( a: & $hir hir:: Block <$hir >) ;
24
- fn check_block_post( a: & $hir hir:: Block <$hir >) ;
25
- fn check_stmt( a: & $hir hir:: Stmt <$hir >) ;
26
- fn check_arm( a: & $hir hir:: Arm <$hir >) ;
27
- fn check_pat( a: & $hir hir:: Pat <$hir >) ;
28
- fn check_expr( a: & $hir hir:: Expr <$hir >) ;
29
- fn check_expr_post( a: & $hir hir:: Expr <$hir >) ;
30
- fn check_ty( a: & $hir hir:: Ty <$hir >) ;
31
- fn check_generic_param( a: & $hir hir:: GenericParam <$hir >) ;
32
- fn check_generics( a: & $hir hir:: Generics <$hir >) ;
33
- fn check_poly_trait_ref( a: & $hir hir:: PolyTraitRef <$hir >) ;
18
+ fn check_mod( a: & ' tcx hir:: Mod <' tcx >, b: hir:: HirId ) ;
19
+ fn check_foreign_item( a: & ' tcx hir:: ForeignItem <' tcx >) ;
20
+ fn check_item( a: & ' tcx hir:: Item <' tcx >) ;
21
+ fn check_item_post( a: & ' tcx hir:: Item <' tcx >) ;
22
+ fn check_local( a: & ' tcx hir:: Local <' tcx >) ;
23
+ fn check_block( a: & ' tcx hir:: Block <' tcx >) ;
24
+ fn check_block_post( a: & ' tcx hir:: Block <' tcx >) ;
25
+ fn check_stmt( a: & ' tcx hir:: Stmt <' tcx >) ;
26
+ fn check_arm( a: & ' tcx hir:: Arm <' tcx >) ;
27
+ fn check_pat( a: & ' tcx hir:: Pat <' tcx >) ;
28
+ fn check_expr( a: & ' tcx hir:: Expr <' tcx >) ;
29
+ fn check_expr_post( a: & ' tcx hir:: Expr <' tcx >) ;
30
+ fn check_ty( a: & ' tcx hir:: Ty <' tcx >) ;
31
+ fn check_generic_param( a: & ' tcx hir:: GenericParam <' tcx >) ;
32
+ fn check_generics( a: & ' tcx hir:: Generics <' tcx >) ;
33
+ fn check_poly_trait_ref( a: & ' tcx hir:: PolyTraitRef <' tcx >) ;
34
34
fn check_fn(
35
- a: rustc_hir:: intravisit:: FnKind <$hir >,
36
- b: & $hir hir:: FnDecl <$hir >,
37
- c: & $hir hir:: Body <$hir >,
35
+ a: rustc_hir:: intravisit:: FnKind <' tcx >,
36
+ b: & ' tcx hir:: FnDecl <' tcx >,
37
+ c: & ' tcx hir:: Body <' tcx >,
38
38
d: Span ,
39
39
e: hir:: HirId ) ;
40
- fn check_trait_item( a: & $hir hir:: TraitItem <$hir >) ;
41
- fn check_impl_item( a: & $hir hir:: ImplItem <$hir >) ;
42
- fn check_impl_item_post( a: & $hir hir:: ImplItem <$hir >) ;
43
- fn check_struct_def( a: & $hir hir:: VariantData <$hir >) ;
44
- fn check_field_def( a: & $hir hir:: FieldDef <$hir >) ;
45
- fn check_variant( a: & $hir hir:: Variant <$hir >) ;
46
- fn check_path( a: & hir:: Path <$hir >, b: hir:: HirId ) ;
47
- fn check_attribute( a: & $hir ast:: Attribute ) ;
40
+ fn check_trait_item( a: & ' tcx hir:: TraitItem <' tcx >) ;
41
+ fn check_impl_item( a: & ' tcx hir:: ImplItem <' tcx >) ;
42
+ fn check_impl_item_post( a: & ' tcx hir:: ImplItem <' tcx >) ;
43
+ fn check_struct_def( a: & ' tcx hir:: VariantData <' tcx >) ;
44
+ fn check_field_def( a: & ' tcx hir:: FieldDef <' tcx >) ;
45
+ fn check_variant( a: & ' tcx hir:: Variant <' tcx >) ;
46
+ fn check_path( a: & hir:: Path <' tcx >, b: hir:: HirId ) ;
47
+ fn check_attribute( a: & ' tcx ast:: Attribute ) ;
48
48
49
49
/// Called when entering a syntax node that can have lint attributes such
50
50
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
51
- fn enter_lint_attrs( a: & $hir [ ast:: Attribute ] ) ;
51
+ fn enter_lint_attrs( a: & ' tcx [ ast:: Attribute ] ) ;
52
52
53
53
/// Counterpart to `enter_lint_attrs`.
54
- fn exit_lint_attrs( a: & $hir [ ast:: Attribute ] ) ;
54
+ fn exit_lint_attrs( a: & ' tcx [ ast:: Attribute ] ) ;
55
55
] ) ;
56
56
)
57
57
}
@@ -66,21 +66,23 @@ macro_rules! late_lint_methods {
66
66
// contains a few lint-specific methods with no equivalent in `Visitor`.
67
67
68
68
macro_rules! declare_late_lint_pass {
69
- ( [ ] , [ $hir : tt ] , [ $ ( $( #[ $attr: meta] ) * fn $name: ident( $( $param: ident: $arg: ty) ,* ) ; ) * ] ) => (
70
- pub trait LateLintPass <$hir >: LintPass {
71
- $( #[ inline( always) ] fn $name( & mut self , _: & LateContext <$hir >, $( _: $arg) ,* ) { } ) *
69
+ ( [ ] , [ $( $( #[ $attr: meta] ) * fn $name: ident( $( $param: ident: $arg: ty) ,* ) ; ) * ] ) => (
70
+ pub trait LateLintPass <' tcx >: LintPass {
71
+ $( #[ inline( always) ] fn $name( & mut self , _: & LateContext <' tcx >, $( _: $arg) ,* ) { } ) *
72
72
}
73
73
)
74
74
}
75
75
76
- late_lint_methods ! ( declare_late_lint_pass, [ ] , [ ' tcx] ) ;
76
+ // Declare the `LateLintPass` trait, which contains empty default definitions
77
+ // for all the `check_*` methods.
78
+ late_lint_methods ! ( declare_late_lint_pass, [ ] ) ;
77
79
78
80
impl LateLintPass < ' _ > for HardwiredLints { }
79
81
80
82
#[ macro_export]
81
83
macro_rules! expand_combined_late_lint_pass_method {
82
- ( [ $( $passes : ident) ,* ] , $self: ident, $name: ident, $params: tt) => ( {
83
- $( $self. $passes . $name $params; ) *
84
+ ( [ $( $pass : ident) ,* ] , $self: ident, $name: ident, $params: tt) => ( {
85
+ $( $self. $pass . $name $params; ) *
84
86
} )
85
87
}
86
88
@@ -95,28 +97,28 @@ macro_rules! expand_combined_late_lint_pass_methods {
95
97
96
98
#[ macro_export]
97
99
macro_rules! declare_combined_late_lint_pass {
98
- ( [ $v: vis $name: ident, [ $( $passes : ident: $constructor: expr, ) * ] ] , [ $hir : tt ] , $methods: tt) => (
100
+ ( [ $v: vis $name: ident, [ $( $pass : ident: $constructor: expr, ) * ] ] , $methods: tt) => (
99
101
#[ allow( non_snake_case) ]
100
102
$v struct $name {
101
- $( $passes : $passes , ) *
103
+ $( $pass : $pass , ) *
102
104
}
103
105
104
106
impl $name {
105
107
$v fn new( ) -> Self {
106
108
Self {
107
- $( $passes : $constructor, ) *
109
+ $( $pass : $constructor, ) *
108
110
}
109
111
}
110
112
111
113
$v fn get_lints( ) -> LintArray {
112
114
let mut lints = Vec :: new( ) ;
113
- $( lints. extend_from_slice( & $passes :: get_lints( ) ) ; ) *
115
+ $( lints. extend_from_slice( & $pass :: get_lints( ) ) ; ) *
114
116
lints
115
117
}
116
118
}
117
119
118
120
impl <' tcx> LateLintPass <' tcx> for $name {
119
- expand_combined_late_lint_pass_methods!( [ $( $passes ) ,* ] , $methods) ;
121
+ expand_combined_late_lint_pass_methods!( [ $( $pass ) ,* ] , $methods) ;
120
122
}
121
123
122
124
#[ allow( rustc:: lint_pass_impl_without_macro) ]
@@ -176,12 +178,14 @@ macro_rules! declare_early_lint_pass {
176
178
)
177
179
}
178
180
181
+ // Declare the `EarlyLintPass` trait, which contains empty default definitions
182
+ // for all the `check_*` methods.
179
183
early_lint_methods ! ( declare_early_lint_pass, [ ] ) ;
180
184
181
185
#[ macro_export]
182
186
macro_rules! expand_combined_early_lint_pass_method {
183
- ( [ $( $passes : ident) ,* ] , $self: ident, $name: ident, $params: tt) => ( {
184
- $( $self. $passes . $name $params; ) *
187
+ ( [ $( $pass : ident) ,* ] , $self: ident, $name: ident, $params: tt) => ( {
188
+ $( $self. $pass . $name $params; ) *
185
189
} )
186
190
}
187
191
@@ -196,28 +200,28 @@ macro_rules! expand_combined_early_lint_pass_methods {
196
200
197
201
#[ macro_export]
198
202
macro_rules! declare_combined_early_lint_pass {
199
- ( [ $v: vis $name: ident, [ $( $passes : ident: $constructor: expr, ) * ] ] , $methods: tt) => (
203
+ ( [ $v: vis $name: ident, [ $( $pass : ident: $constructor: expr, ) * ] ] , $methods: tt) => (
200
204
#[ allow( non_snake_case) ]
201
205
$v struct $name {
202
- $( $passes : $passes , ) *
206
+ $( $pass : $pass , ) *
203
207
}
204
208
205
209
impl $name {
206
210
$v fn new( ) -> Self {
207
211
Self {
208
- $( $passes : $constructor, ) *
212
+ $( $pass : $constructor, ) *
209
213
}
210
214
}
211
215
212
216
$v fn get_lints( ) -> LintArray {
213
217
let mut lints = Vec :: new( ) ;
214
- $( lints. extend_from_slice( & $passes :: get_lints( ) ) ; ) *
218
+ $( lints. extend_from_slice( & $pass :: get_lints( ) ) ; ) *
215
219
lints
216
220
}
217
221
}
218
222
219
223
impl EarlyLintPass for $name {
220
- expand_combined_early_lint_pass_methods!( [ $( $passes ) ,* ] , $methods) ;
224
+ expand_combined_early_lint_pass_methods!( [ $( $pass ) ,* ] , $methods) ;
221
225
}
222
226
223
227
#[ allow( rustc:: lint_pass_impl_without_macro) ]
0 commit comments