1
1
use crate :: context:: { EarlyContext , LateContext } ;
2
2
3
- use rustc_ast as ast;
4
- use rustc_hir as hir;
5
3
use rustc_session:: lint:: builtin:: HardwiredLints ;
6
4
use rustc_session:: lint:: LintPass ;
7
- use rustc_span:: def_id:: LocalDefId ;
8
- use rustc_span:: symbol:: Ident ;
9
- use rustc_span:: Span ;
10
5
11
6
#[ macro_export]
12
7
macro_rules! late_lint_methods {
13
8
( $macro: path, $args: tt) => (
14
9
$macro!( $args, [
15
- fn check_body( a: & ' tcx hir :: Body <' tcx>) ;
16
- fn check_body_post( a: & ' tcx hir :: Body <' tcx>) ;
10
+ fn check_body( a: & ' tcx rustc_hir :: Body <' tcx>) ;
11
+ fn check_body_post( a: & ' tcx rustc_hir :: Body <' tcx>) ;
17
12
fn check_crate( ) ;
18
13
fn check_crate_post( ) ;
19
- fn check_mod( a: & ' tcx hir :: Mod <' tcx>, b: hir :: HirId ) ;
20
- fn check_foreign_item( a: & ' tcx hir :: ForeignItem <' tcx>) ;
21
- fn check_item( a: & ' tcx hir :: Item <' tcx>) ;
22
- fn check_item_post( a: & ' tcx hir :: Item <' tcx>) ;
23
- fn check_local( a: & ' tcx hir :: Local <' tcx>) ;
24
- fn check_block( a: & ' tcx hir :: Block <' tcx>) ;
25
- fn check_block_post( a: & ' tcx hir :: Block <' tcx>) ;
26
- fn check_stmt( a: & ' tcx hir :: Stmt <' tcx>) ;
27
- fn check_arm( a: & ' tcx hir :: Arm <' tcx>) ;
28
- fn check_pat( a: & ' tcx hir :: Pat <' tcx>) ;
29
- fn check_expr( a: & ' tcx hir :: Expr <' tcx>) ;
30
- fn check_expr_post( a: & ' tcx hir :: Expr <' tcx>) ;
31
- fn check_ty( a: & ' tcx hir :: Ty <' tcx>) ;
32
- fn check_generic_param( a: & ' tcx hir :: GenericParam <' tcx>) ;
33
- fn check_generics( a: & ' tcx hir :: Generics <' tcx>) ;
34
- fn check_poly_trait_ref( a: & ' tcx hir :: PolyTraitRef <' tcx>) ;
14
+ fn check_mod( a: & ' tcx rustc_hir :: Mod <' tcx>, b: rustc_hir :: HirId ) ;
15
+ fn check_foreign_item( a: & ' tcx rustc_hir :: ForeignItem <' tcx>) ;
16
+ fn check_item( a: & ' tcx rustc_hir :: Item <' tcx>) ;
17
+ fn check_item_post( a: & ' tcx rustc_hir :: Item <' tcx>) ;
18
+ fn check_local( a: & ' tcx rustc_hir :: Local <' tcx>) ;
19
+ fn check_block( a: & ' tcx rustc_hir :: Block <' tcx>) ;
20
+ fn check_block_post( a: & ' tcx rustc_hir :: Block <' tcx>) ;
21
+ fn check_stmt( a: & ' tcx rustc_hir :: Stmt <' tcx>) ;
22
+ fn check_arm( a: & ' tcx rustc_hir :: Arm <' tcx>) ;
23
+ fn check_pat( a: & ' tcx rustc_hir :: Pat <' tcx>) ;
24
+ fn check_expr( a: & ' tcx rustc_hir :: Expr <' tcx>) ;
25
+ fn check_expr_post( a: & ' tcx rustc_hir :: Expr <' tcx>) ;
26
+ fn check_ty( a: & ' tcx rustc_hir :: Ty <' tcx>) ;
27
+ fn check_generic_param( a: & ' tcx rustc_hir :: GenericParam <' tcx>) ;
28
+ fn check_generics( a: & ' tcx rustc_hir :: Generics <' tcx>) ;
29
+ fn check_poly_trait_ref( a: & ' tcx rustc_hir :: PolyTraitRef <' tcx>) ;
35
30
fn check_fn(
36
31
a: rustc_hir:: intravisit:: FnKind <' tcx>,
37
- b: & ' tcx hir :: FnDecl <' tcx>,
38
- c: & ' tcx hir :: Body <' tcx>,
39
- d: Span ,
40
- e: LocalDefId ) ;
41
- fn check_trait_item( a: & ' tcx hir :: TraitItem <' tcx>) ;
42
- fn check_impl_item( a: & ' tcx hir :: ImplItem <' tcx>) ;
43
- fn check_impl_item_post( a: & ' tcx hir :: ImplItem <' tcx>) ;
44
- fn check_struct_def( a: & ' tcx hir :: VariantData <' tcx>) ;
45
- fn check_field_def( a: & ' tcx hir :: FieldDef <' tcx>) ;
46
- fn check_variant( a: & ' tcx hir :: Variant <' tcx>) ;
47
- fn check_path( a: & hir :: Path <' tcx>, b: hir :: HirId ) ;
48
- fn check_attribute( a: & ' tcx ast :: Attribute ) ;
32
+ b: & ' tcx rustc_hir :: FnDecl <' tcx>,
33
+ c: & ' tcx rustc_hir :: Body <' tcx>,
34
+ d: rustc_span :: Span ,
35
+ e: rustc_span :: def_id :: LocalDefId ) ;
36
+ fn check_trait_item( a: & ' tcx rustc_hir :: TraitItem <' tcx>) ;
37
+ fn check_impl_item( a: & ' tcx rustc_hir :: ImplItem <' tcx>) ;
38
+ fn check_impl_item_post( a: & ' tcx rustc_hir :: ImplItem <' tcx>) ;
39
+ fn check_struct_def( a: & ' tcx rustc_hir :: VariantData <' tcx>) ;
40
+ fn check_field_def( a: & ' tcx rustc_hir :: FieldDef <' tcx>) ;
41
+ fn check_variant( a: & ' tcx rustc_hir :: Variant <' tcx>) ;
42
+ fn check_path( a: & rustc_hir :: Path <' tcx>, b: rustc_hir :: HirId ) ;
43
+ fn check_attribute( a: & ' tcx rustc_ast :: Attribute ) ;
49
44
50
45
/// Called when entering a syntax node that can have lint attributes such
51
46
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
52
- fn enter_lint_attrs( a: & ' tcx [ ast :: Attribute ] ) ;
47
+ fn enter_lint_attrs( a: & ' tcx [ rustc_ast :: Attribute ] ) ;
53
48
54
49
/// Counterpart to `enter_lint_attrs`.
55
- fn exit_lint_attrs( a: & ' tcx [ ast :: Attribute ] ) ;
50
+ fn exit_lint_attrs( a: & ' tcx [ rustc_ast :: Attribute ] ) ;
56
51
] ) ;
57
52
)
58
53
}
@@ -90,8 +85,8 @@ macro_rules! expand_combined_late_lint_pass_method {
90
85
#[ macro_export]
91
86
macro_rules! expand_combined_late_lint_pass_methods {
92
87
( $passes: tt, [ $( $( #[ $attr: meta] ) * fn $name: ident( $( $param: ident: $arg: ty) ,* ) ; ) * ] ) => (
93
- $( fn $name( & mut self , context: & LateContext <' tcx>, $( $param: $arg) ,* ) {
94
- expand_combined_late_lint_pass_method!( $passes, self , $name, ( context, $( $param) ,* ) ) ;
88
+ $( fn $name( & mut self , context: & $crate :: LateContext <' tcx>, $( $param: $arg) ,* ) {
89
+ $crate :: expand_combined_late_lint_pass_method!( $passes, self , $name, ( context, $( $param) ,* ) ) ;
95
90
} ) *
96
91
)
97
92
}
@@ -116,19 +111,19 @@ macro_rules! declare_combined_late_lint_pass {
116
111
}
117
112
}
118
113
119
- $v fn get_lints( ) -> LintArray {
114
+ $v fn get_lints( ) -> $crate :: LintArray {
120
115
let mut lints = Vec :: new( ) ;
121
116
$( lints. extend_from_slice( & $pass:: get_lints( ) ) ; ) *
122
117
lints
123
118
}
124
119
}
125
120
126
- impl <' tcx> LateLintPass <' tcx> for $name {
127
- expand_combined_late_lint_pass_methods!( [ $( $pass) ,* ] , $methods) ;
121
+ impl <' tcx> $crate :: LateLintPass <' tcx> for $name {
122
+ $crate :: expand_combined_late_lint_pass_methods!( [ $( $pass) ,* ] , $methods) ;
128
123
}
129
124
130
125
#[ allow( rustc:: lint_pass_impl_without_macro) ]
131
- impl LintPass for $name {
126
+ impl $crate :: LintPass for $name {
132
127
fn name( & self ) -> & ' static str {
133
128
panic!( )
134
129
}
@@ -140,42 +135,45 @@ macro_rules! declare_combined_late_lint_pass {
140
135
macro_rules! early_lint_methods {
141
136
( $macro: path, $args: tt) => (
142
137
$macro!( $args, [
143
- fn check_param( a: & ast:: Param ) ;
144
- fn check_ident( a: Ident ) ;
145
- fn check_crate( a: & ast:: Crate ) ;
146
- fn check_crate_post( a: & ast:: Crate ) ;
147
- fn check_item( a: & ast:: Item ) ;
148
- fn check_item_post( a: & ast:: Item ) ;
149
- fn check_local( a: & ast:: Local ) ;
150
- fn check_block( a: & ast:: Block ) ;
151
- fn check_stmt( a: & ast:: Stmt ) ;
152
- fn check_arm( a: & ast:: Arm ) ;
153
- fn check_pat( a: & ast:: Pat ) ;
154
- fn check_pat_post( a: & ast:: Pat ) ;
155
- fn check_expr( a: & ast:: Expr ) ;
156
- fn check_expr_post( a: & ast:: Expr ) ;
157
- fn check_ty( a: & ast:: Ty ) ;
158
- fn check_generic_arg( a: & ast:: GenericArg ) ;
159
- fn check_generic_param( a: & ast:: GenericParam ) ;
160
- fn check_generics( a: & ast:: Generics ) ;
161
- fn check_poly_trait_ref( a: & ast:: PolyTraitRef ) ;
162
- fn check_fn( a: rustc_ast:: visit:: FnKind <' _>, c: Span , d_: ast:: NodeId ) ;
163
- fn check_trait_item( a: & ast:: AssocItem ) ;
164
- fn check_impl_item( a: & ast:: AssocItem ) ;
165
- fn check_variant( a: & ast:: Variant ) ;
166
- fn check_attribute( a: & ast:: Attribute ) ;
167
- fn check_mac_def( a: & ast:: MacroDef ) ;
168
- fn check_mac( a: & ast:: MacCall ) ;
138
+ fn check_param( a: & rustc_ast:: Param ) ;
139
+ fn check_ident( a: rustc_span:: symbol:: Ident ) ;
140
+ fn check_crate( a: & rustc_ast:: Crate ) ;
141
+ fn check_crate_post( a: & rustc_ast:: Crate ) ;
142
+ fn check_item( a: & rustc_ast:: Item ) ;
143
+ fn check_item_post( a: & rustc_ast:: Item ) ;
144
+ fn check_local( a: & rustc_ast:: Local ) ;
145
+ fn check_block( a: & rustc_ast:: Block ) ;
146
+ fn check_stmt( a: & rustc_ast:: Stmt ) ;
147
+ fn check_arm( a: & rustc_ast:: Arm ) ;
148
+ fn check_pat( a: & rustc_ast:: Pat ) ;
149
+ fn check_pat_post( a: & rustc_ast:: Pat ) ;
150
+ fn check_expr( a: & rustc_ast:: Expr ) ;
151
+ fn check_expr_post( a: & rustc_ast:: Expr ) ;
152
+ fn check_ty( a: & rustc_ast:: Ty ) ;
153
+ fn check_generic_arg( a: & rustc_ast:: GenericArg ) ;
154
+ fn check_generic_param( a: & rustc_ast:: GenericParam ) ;
155
+ fn check_generics( a: & rustc_ast:: Generics ) ;
156
+ fn check_poly_trait_ref( a: & rustc_ast:: PolyTraitRef ) ;
157
+ fn check_fn(
158
+ a: rustc_ast:: visit:: FnKind <' _>,
159
+ c: rustc_span:: Span ,
160
+ d_: rustc_ast:: NodeId ) ;
161
+ fn check_trait_item( a: & rustc_ast:: AssocItem ) ;
162
+ fn check_impl_item( a: & rustc_ast:: AssocItem ) ;
163
+ fn check_variant( a: & rustc_ast:: Variant ) ;
164
+ fn check_attribute( a: & rustc_ast:: Attribute ) ;
165
+ fn check_mac_def( a: & rustc_ast:: MacroDef ) ;
166
+ fn check_mac( a: & rustc_ast:: MacCall ) ;
169
167
170
168
/// Called when entering a syntax node that can have lint attributes such
171
169
/// as `#[allow(...)]`. Called with *all* the attributes of that node.
172
- fn enter_lint_attrs( a: & [ ast :: Attribute ] ) ;
170
+ fn enter_lint_attrs( a: & [ rustc_ast :: Attribute ] ) ;
173
171
174
172
/// Counterpart to `enter_lint_attrs`.
175
- fn exit_lint_attrs( a: & [ ast :: Attribute ] ) ;
173
+ fn exit_lint_attrs( a: & [ rustc_ast :: Attribute ] ) ;
176
174
177
- fn enter_where_predicate( a: & ast :: WherePredicate ) ;
178
- fn exit_where_predicate( a: & ast :: WherePredicate ) ;
175
+ fn enter_where_predicate( a: & rustc_ast :: WherePredicate ) ;
176
+ fn exit_where_predicate( a: & rustc_ast :: WherePredicate ) ;
179
177
] ) ;
180
178
)
181
179
}
@@ -202,8 +200,8 @@ macro_rules! expand_combined_early_lint_pass_method {
202
200
#[ macro_export]
203
201
macro_rules! expand_combined_early_lint_pass_methods {
204
202
( $passes: tt, [ $( $( #[ $attr: meta] ) * fn $name: ident( $( $param: ident: $arg: ty) ,* ) ; ) * ] ) => (
205
- $( fn $name( & mut self , context: & EarlyContext <' _>, $( $param: $arg) ,* ) {
206
- expand_combined_early_lint_pass_method!( $passes, self , $name, ( context, $( $param) ,* ) ) ;
203
+ $( fn $name( & mut self , context: & $crate :: EarlyContext <' _>, $( $param: $arg) ,* ) {
204
+ $crate :: expand_combined_early_lint_pass_method!( $passes, self , $name, ( context, $( $param) ,* ) ) ;
207
205
} ) *
208
206
)
209
207
}
@@ -228,19 +226,19 @@ macro_rules! declare_combined_early_lint_pass {
228
226
}
229
227
}
230
228
231
- $v fn get_lints( ) -> LintArray {
229
+ $v fn get_lints( ) -> $crate :: LintArray {
232
230
let mut lints = Vec :: new( ) ;
233
231
$( lints. extend_from_slice( & $pass:: get_lints( ) ) ; ) *
234
232
lints
235
233
}
236
234
}
237
235
238
- impl EarlyLintPass for $name {
239
- expand_combined_early_lint_pass_methods!( [ $( $pass) ,* ] , $methods) ;
236
+ impl $crate :: EarlyLintPass for $name {
237
+ $crate :: expand_combined_early_lint_pass_methods!( [ $( $pass) ,* ] , $methods) ;
240
238
}
241
239
242
240
#[ allow( rustc:: lint_pass_impl_without_macro) ]
243
- impl LintPass for $name {
241
+ impl $crate :: LintPass for $name {
244
242
fn name( & self ) -> & ' static str {
245
243
panic!( )
246
244
}
0 commit comments