Skip to content

Commit 17b1026

Browse files
committed
Use absolute paths in rustc_lint::passes macros
A cosmetic change, so the callsite doesn't have to import things
1 parent 8bf0dec commit 17b1026

File tree

2 files changed

+78
-84
lines changed

2 files changed

+78
-84
lines changed

compiler/rustc_lint/src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,14 @@ mod unused;
8686

8787
pub use array_into_iter::ARRAY_INTO_ITER;
8888

89-
use rustc_ast as ast;
9089
use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage};
9190
use rustc_fluent_macro::fluent_messages;
92-
use rustc_hir as hir;
93-
use rustc_hir::def_id::{LocalDefId, LocalModDefId};
91+
use rustc_hir::def_id::LocalModDefId;
9492
use rustc_middle::query::Providers;
9593
use rustc_middle::ty::TyCtxt;
9694
use rustc_session::lint::builtin::{
9795
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
9896
};
99-
use rustc_span::symbol::Ident;
100-
use rustc_span::Span;
10197

10298
use array_into_iter::ArrayIntoIter;
10399
use builtin::*;

compiler/rustc_lint/src/passes.rs

+77-79
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,53 @@
11
use crate::context::{EarlyContext, LateContext};
22

3-
use rustc_ast as ast;
4-
use rustc_hir as hir;
53
use rustc_session::lint::builtin::HardwiredLints;
64
use rustc_session::lint::LintPass;
7-
use rustc_span::def_id::LocalDefId;
8-
use rustc_span::symbol::Ident;
9-
use rustc_span::Span;
105

116
#[macro_export]
127
macro_rules! late_lint_methods {
138
($macro:path, $args:tt) => (
149
$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>);
1712
fn check_crate();
1813
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>);
3530
fn check_fn(
3631
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);
4944

5045
/// Called when entering a syntax node that can have lint attributes such
5146
/// 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]);
5348

5449
/// Counterpart to `enter_lint_attrs`.
55-
fn exit_lint_attrs(a: &'tcx [ast::Attribute]);
50+
fn exit_lint_attrs(a: &'tcx [rustc_ast::Attribute]);
5651
]);
5752
)
5853
}
@@ -90,8 +85,8 @@ macro_rules! expand_combined_late_lint_pass_method {
9085
#[macro_export]
9186
macro_rules! expand_combined_late_lint_pass_methods {
9287
($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),*));
9590
})*
9691
)
9792
}
@@ -116,19 +111,19 @@ macro_rules! declare_combined_late_lint_pass {
116111
}
117112
}
118113

119-
$v fn get_lints() -> LintArray {
114+
$v fn get_lints() -> $crate::LintArray {
120115
let mut lints = Vec::new();
121116
$(lints.extend_from_slice(&$pass::get_lints());)*
122117
lints
123118
}
124119
}
125120

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);
128123
}
129124

130125
#[allow(rustc::lint_pass_impl_without_macro)]
131-
impl LintPass for $name {
126+
impl $crate::LintPass for $name {
132127
fn name(&self) -> &'static str {
133128
panic!()
134129
}
@@ -140,42 +135,45 @@ macro_rules! declare_combined_late_lint_pass {
140135
macro_rules! early_lint_methods {
141136
($macro:path, $args:tt) => (
142137
$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);
169167

170168
/// Called when entering a syntax node that can have lint attributes such
171169
/// 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]);
173171

174172
/// Counterpart to `enter_lint_attrs`.
175-
fn exit_lint_attrs(a: &[ast::Attribute]);
173+
fn exit_lint_attrs(a: &[rustc_ast::Attribute]);
176174

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);
179177
]);
180178
)
181179
}
@@ -202,8 +200,8 @@ macro_rules! expand_combined_early_lint_pass_method {
202200
#[macro_export]
203201
macro_rules! expand_combined_early_lint_pass_methods {
204202
($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),*));
207205
})*
208206
)
209207
}
@@ -228,19 +226,19 @@ macro_rules! declare_combined_early_lint_pass {
228226
}
229227
}
230228

231-
$v fn get_lints() -> LintArray {
229+
$v fn get_lints() -> $crate::LintArray {
232230
let mut lints = Vec::new();
233231
$(lints.extend_from_slice(&$pass::get_lints());)*
234232
lints
235233
}
236234
}
237235

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);
240238
}
241239

242240
#[allow(rustc::lint_pass_impl_without_macro)]
243-
impl LintPass for $name {
241+
impl $crate::LintPass for $name {
244242
fn name(&self) -> &'static str {
245243
panic!()
246244
}

0 commit comments

Comments
 (0)