@@ -101,12 +101,11 @@ impl LateLintPass<'_, '_> for WildcardImports {
101
101
return ;
102
102
}
103
103
if is_test_module_or_function ( item) {
104
- self . test_modules_deep += 1 ;
104
+ self . test_modules_deep = self . test_modules_deep . saturating_add ( 1 ) ;
105
105
}
106
106
if_chain ! {
107
- if self . warn_on_all || !in_macro( item. span) ;
108
107
if let ItemKind :: Use ( use_path, UseKind :: Glob ) = & item. kind;
109
- if self . warn_on_all || !self . check_exceptions( use_path. segments) ;
108
+ if self . warn_on_all || !self . check_exceptions( item , use_path. segments) ;
110
109
let used_imports = cx. tcx. names_imported_by_glob_use( item. hir_id. owner) ;
111
110
if !used_imports. is_empty( ) ; // Already handled by `unused_imports`
112
111
then {
@@ -177,14 +176,16 @@ impl LateLintPass<'_, '_> for WildcardImports {
177
176
178
177
fn check_item_post ( & mut self , _: & LateContext < ' _ , ' _ > , item : & Item < ' _ > ) {
179
178
if is_test_module_or_function ( item) {
180
- self . test_modules_deep -= 1 ;
179
+ self . test_modules_deep = self . test_modules_deep . saturating_sub ( 1 ) ;
181
180
}
182
181
}
183
182
}
184
183
185
184
impl WildcardImports {
186
- fn check_exceptions ( & self , segments : & [ PathSegment < ' _ > ] ) -> bool {
187
- is_prelude_import ( segments) || ( is_super_only_import ( segments) && self . test_modules_deep > 0 )
185
+ fn check_exceptions ( & self , item : & Item < ' _ > , segments : & [ PathSegment < ' _ > ] ) -> bool {
186
+ in_macro ( item. span )
187
+ || is_prelude_import ( segments)
188
+ || ( is_super_only_import ( segments) && self . test_modules_deep > 0 )
188
189
}
189
190
}
190
191
0 commit comments