@@ -8,7 +8,6 @@ use rustc_errors::Applicability;
8
8
use rustc_hir as hir;
9
9
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
10
10
use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
11
- use rustc_span:: hygiene:: ExpnKind ;
12
11
use rustc_span:: { edition:: Edition , sym, Span } ;
13
12
14
13
declare_clippy_lint ! {
@@ -97,42 +96,42 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
97
96
if let Res :: Def ( DefKind :: Mod , id) = path. res;
98
97
if !id. is_local( ) ;
99
98
then {
100
- for kid in cx. tcx. item_children ( id) . iter( ) {
99
+ for kid in cx. tcx. module_children ( id) . iter( ) {
101
100
if let Res :: Def ( DefKind :: Macro ( _mac_type) , mac_id) = kid. res {
102
101
let span = mac_attr. span;
103
102
let def_path = cx. tcx. def_path_str( mac_id) ;
104
103
self . imports. push( ( def_path, span) ) ;
105
104
}
106
105
}
107
106
} else {
108
- if in_macro ( item. span) {
107
+ if item. span. from_expansion ( ) {
109
108
self . push_unique_macro_pat_ty( cx, item. span) ;
110
109
}
111
110
}
112
111
}
113
112
}
114
113
fn check_attribute ( & mut self , cx : & LateContext < ' _ > , attr : & ast:: Attribute ) {
115
- if in_macro ( attr. span ) {
114
+ if attr. span . from_expansion ( ) {
116
115
self . push_unique_macro ( cx, attr. span ) ;
117
116
}
118
117
}
119
118
fn check_expr ( & mut self , cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > ) {
120
- if in_macro ( expr. span ) {
119
+ if expr. span . from_expansion ( ) {
121
120
self . push_unique_macro ( cx, expr. span ) ;
122
121
}
123
122
}
124
123
fn check_stmt ( & mut self , cx : & LateContext < ' _ > , stmt : & hir:: Stmt < ' _ > ) {
125
- if in_macro ( stmt. span ) {
124
+ if stmt. span . from_expansion ( ) {
126
125
self . push_unique_macro ( cx, stmt. span ) ;
127
126
}
128
127
}
129
128
fn check_pat ( & mut self , cx : & LateContext < ' _ > , pat : & hir:: Pat < ' _ > ) {
130
- if in_macro ( pat. span ) {
129
+ if pat. span . from_expansion ( ) {
131
130
self . push_unique_macro_pat_ty ( cx, pat. span ) ;
132
131
}
133
132
}
134
133
fn check_ty ( & mut self , cx : & LateContext < ' _ > , ty : & hir:: Ty < ' _ > ) {
135
- if in_macro ( ty. span ) {
134
+ if ty. span . from_expansion ( ) {
136
135
self . push_unique_macro_pat_ty ( cx, ty. span ) ;
137
136
}
138
137
}
@@ -214,7 +213,3 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
214
213
}
215
214
}
216
215
}
217
-
218
- fn in_macro ( span : Span ) -> bool {
219
- span. from_expansion ( ) && !matches ! ( span. ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: Desugaring ( ..) )
220
- }
0 commit comments