@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
2
2
use clippy_utils:: source:: HasSession ;
3
3
use rustc_errors:: Applicability ;
4
4
use rustc_hir:: def:: { DefKind , Res } ;
5
- use rustc_hir:: { Item , ItemKind } ;
5
+ use rustc_hir:: { Item , ItemKind , UseKind } ;
6
6
use rustc_lint:: { LateContext , LateLintPass } ;
7
7
use rustc_middle:: ty;
8
8
use rustc_session:: impl_lint_pass;
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
49
49
if cx. tcx . visibility ( item. owner_id . def_id ) == ty:: Visibility :: Restricted ( CRATE_DEF_ID . to_def_id ( ) )
50
50
&& !cx. effective_visibilities . is_exported ( item. owner_id . def_id )
51
51
&& self . is_exported . last ( ) == Some ( & false )
52
- && is_not_macro_export ( item)
52
+ && ! is_ignorable_export ( item)
53
53
&& !item. span . in_external_macro ( cx. sess ( ) . source_map ( ) )
54
54
{
55
55
let span = item
@@ -86,18 +86,17 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
86
86
}
87
87
}
88
88
89
- fn is_not_macro_export < ' tcx > ( item : & ' tcx Item < ' tcx > ) -> bool {
90
- if let ItemKind :: Use ( path, _) = item. kind {
91
- if path
92
- . res
93
- . iter ( )
94
- . all ( |res| matches ! ( res, Res :: Def ( DefKind :: Macro ( MacroKind :: Bang ) , _) ) )
95
- {
96
- return false ;
89
+ // We ignore macro exports. And `ListStem` uses, which aren't interesting.
90
+ fn is_ignorable_export < ' tcx > ( item : & ' tcx Item < ' tcx > ) -> bool {
91
+ if let ItemKind :: Use ( path, kind) = item. kind {
92
+ let ignore = matches ! ( path. res. macro_ns, Some ( Res :: Def ( DefKind :: Macro ( MacroKind :: Bang ) , _) ) )
93
+ || kind == UseKind :: ListStem ;
94
+ if ignore {
95
+ return true ;
97
96
}
98
97
} else if let ItemKind :: Macro ( ..) = item. kind {
99
- return false ;
98
+ return true ;
100
99
}
101
100
102
- true
101
+ false
103
102
}
0 commit comments