@@ -2,6 +2,7 @@ use super::utils::{extract_clippy_lint, is_lint_level, is_word};
2
2
use super :: { Attribute , USELESS_ATTRIBUTE } ;
3
3
use clippy_utils:: diagnostics:: span_lint_and_then;
4
4
use clippy_utils:: source:: { first_line_of_span, snippet_opt} ;
5
+ use rustc_ast:: NestedMetaItem ;
5
6
use rustc_errors:: Applicability ;
6
7
use rustc_hir:: { Item , ItemKind } ;
7
8
use rustc_lint:: { LateContext , LintContext } ;
@@ -20,31 +21,40 @@ pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute])
20
21
for lint in lint_list {
21
22
match item. kind {
22
23
ItemKind :: Use ( ..) => {
23
- if is_word ( lint, sym:: unused_imports)
24
- || is_word ( lint, sym:: deprecated)
25
- || is_word ( lint, sym ! ( unreachable_pub) )
26
- || is_word ( lint, sym ! ( unused) )
27
- || is_word ( lint, sym ! ( unused_import_braces) )
28
- || is_word ( lint, sym ! ( unused_braces) )
29
- || is_word ( lint, sym:: dead_code)
30
- || is_word ( lint, sym ! ( hidden_glob_reexports) )
31
- || is_word ( lint, sym ! ( ambiguous_glob_reexports) )
32
- || extract_clippy_lint ( lint) . map_or ( false , |s| {
33
- matches ! (
34
- s. as_str( ) ,
35
- "wildcard_imports"
36
- | "enum_glob_use"
37
- | "redundant_pub_crate"
38
- | "macro_use_imports"
39
- | "unsafe_removed_from_name"
40
- | "module_name_repetitions"
41
- | "single_component_path_imports"
42
- | "disallowed_types"
43
- )
44
- } )
24
+ if let NestedMetaItem :: MetaItem ( meta_item) = lint
25
+ && meta_item. is_word ( )
26
+ && let Some ( ident) = meta_item. ident ( )
27
+ && matches ! (
28
+ ident. name. as_str( ) ,
29
+ "ambiguous_glob_reexports"
30
+ | "dead_code"
31
+ | "deprecated"
32
+ | "hidden_glob_reexports"
33
+ | "unreachable_pub"
34
+ | "unused"
35
+ | "unused_braces"
36
+ | "unused_import_braces"
37
+ | "unused_imports"
38
+ )
45
39
{
46
40
return ;
47
41
}
42
+
43
+ if extract_clippy_lint ( lint) . is_some_and ( |symbol| {
44
+ matches ! (
45
+ symbol. as_str( ) ,
46
+ "wildcard_imports"
47
+ | "enum_glob_use"
48
+ | "redundant_pub_crate"
49
+ | "macro_use_imports"
50
+ | "unsafe_removed_from_name"
51
+ | "module_name_repetitions"
52
+ | "single_component_path_imports"
53
+ | "disallowed_types"
54
+ )
55
+ } ) {
56
+ return ;
57
+ }
48
58
} ,
49
59
ItemKind :: ExternCrate ( ..) => {
50
60
if is_word ( lint, sym:: unused_imports) && skip_unused_imports {
0 commit comments