@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_then;
22use clippy_utils:: source:: HasSession ;
33use rustc_errors:: Applicability ;
44use rustc_hir:: def:: { DefKind , Res } ;
5- use rustc_hir:: { Item , ItemKind } ;
5+ use rustc_hir:: { Item , ItemKind , UseKind } ;
66use rustc_lint:: { LateContext , LateLintPass } ;
77use rustc_middle:: ty;
88use rustc_session:: impl_lint_pass;
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
4949 if cx. tcx . visibility ( item. owner_id . def_id ) == ty:: Visibility :: Restricted ( CRATE_DEF_ID . to_def_id ( ) )
5050 && !cx. effective_visibilities . is_exported ( item. owner_id . def_id )
5151 && self . is_exported . last ( ) == Some ( & false )
52- && is_not_macro_export ( item)
52+ && ! is_ignorable_export ( item)
5353 && !item. span . in_external_macro ( cx. sess ( ) . source_map ( ) )
5454 {
5555 let span = item
@@ -86,18 +86,17 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
8686 }
8787}
8888
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 ;
9796 }
9897 } else if let ItemKind :: Macro ( ..) = item. kind {
99- return false ;
98+ return true ;
10099 }
101100
102- true
101+ false
103102}
0 commit comments