@@ -8,7 +8,6 @@ use rustc_errors::Applicability;
88use rustc_hir as hir;
99use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
1010use rustc_session:: { declare_tool_lint, impl_lint_pass} ;
11- use rustc_span:: hygiene:: ExpnKind ;
1211use rustc_span:: { edition:: Edition , sym, Span } ;
1312
1413declare_clippy_lint ! {
@@ -97,42 +96,42 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
9796 if let Res :: Def ( DefKind :: Mod , id) = path. res;
9897 if !id. is_local( ) ;
9998 then {
100- for kid in cx. tcx. item_children ( id) . iter( ) {
99+ for kid in cx. tcx. module_children ( id) . iter( ) {
101100 if let Res :: Def ( DefKind :: Macro ( _mac_type) , mac_id) = kid. res {
102101 let span = mac_attr. span;
103102 let def_path = cx. tcx. def_path_str( mac_id) ;
104103 self . imports. push( ( def_path, span) ) ;
105104 }
106105 }
107106 } else {
108- if in_macro ( item. span) {
107+ if item. span. from_expansion ( ) {
109108 self . push_unique_macro_pat_ty( cx, item. span) ;
110109 }
111110 }
112111 }
113112 }
114113 fn check_attribute ( & mut self , cx : & LateContext < ' _ > , attr : & ast:: Attribute ) {
115- if in_macro ( attr. span ) {
114+ if attr. span . from_expansion ( ) {
116115 self . push_unique_macro ( cx, attr. span ) ;
117116 }
118117 }
119118 fn check_expr ( & mut self , cx : & LateContext < ' _ > , expr : & hir:: Expr < ' _ > ) {
120- if in_macro ( expr. span ) {
119+ if expr. span . from_expansion ( ) {
121120 self . push_unique_macro ( cx, expr. span ) ;
122121 }
123122 }
124123 fn check_stmt ( & mut self , cx : & LateContext < ' _ > , stmt : & hir:: Stmt < ' _ > ) {
125- if in_macro ( stmt. span ) {
124+ if stmt. span . from_expansion ( ) {
126125 self . push_unique_macro ( cx, stmt. span ) ;
127126 }
128127 }
129128 fn check_pat ( & mut self , cx : & LateContext < ' _ > , pat : & hir:: Pat < ' _ > ) {
130- if in_macro ( pat. span ) {
129+ if pat. span . from_expansion ( ) {
131130 self . push_unique_macro_pat_ty ( cx, pat. span ) ;
132131 }
133132 }
134133 fn check_ty ( & mut self , cx : & LateContext < ' _ > , ty : & hir:: Ty < ' _ > ) {
135- if in_macro ( ty. span ) {
134+ if ty. span . from_expansion ( ) {
136135 self . push_unique_macro_pat_ty ( cx, ty. span ) ;
137136 }
138137 }
@@ -214,7 +213,3 @@ impl<'tcx> LateLintPass<'tcx> for MacroUseImports {
214213 }
215214 }
216215}
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