11use clippy_utils:: diagnostics:: { span_lint, span_lint_hir} ;
2- use clippy_utils:: fulfill_or_allowed;
32use rustc_hir:: attrs:: AttributeKind ;
43use rustc_hir:: def_id:: DefId ;
54use rustc_hir:: { self as hir, Attribute , find_attr} ;
65use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
76use rustc_middle:: ty:: AssocContainer ;
7+ use rustc_session:: config:: CrateType ;
88use rustc_session:: declare_lint_pass;
99use rustc_span:: Span ;
1010
@@ -82,15 +82,6 @@ fn check_missing_inline_attrs(
8282 }
8383}
8484
85- fn is_executable_or_proc_macro ( cx : & LateContext < ' _ > ) -> bool {
86- use rustc_session:: config:: CrateType ;
87-
88- cx. tcx
89- . crate_types ( )
90- . iter ( )
91- . any ( |t : & CrateType | matches ! ( t, CrateType :: Executable | CrateType :: ProcMacro ) )
92- }
93-
9485declare_lint_pass ! ( MissingInline => [ MISSING_INLINE_IN_PUBLIC_ITEMS ] ) ;
9586
9687impl < ' tcx > LateLintPass < ' tcx > for MissingInline {
@@ -99,9 +90,11 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
9990 return ;
10091 }
10192
102- if is_executable_or_proc_macro ( cx)
103- // Allow the lint if it is expected, when building with `--test`
104- && !( cx. sess ( ) . is_test_crate ( ) && fulfill_or_allowed ( cx, MISSING_INLINE_IN_PUBLIC_ITEMS , [ it. hir_id ( ) ] ) )
93+ if cx
94+ . tcx
95+ . crate_types ( )
96+ . iter ( )
97+ . any ( |t : & CrateType | matches ! ( t, CrateType :: ProcMacro ) )
10598 {
10699 return ;
107100 }
@@ -157,7 +150,13 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
157150 }
158151
159152 fn check_impl_item ( & mut self , cx : & LateContext < ' tcx > , impl_item : & ' tcx hir:: ImplItem < ' _ > ) {
160- if impl_item. span . in_external_macro ( cx. sess ( ) . source_map ( ) ) || is_executable_or_proc_macro ( cx) {
153+ if impl_item. span . in_external_macro ( cx. sess ( ) . source_map ( ) )
154+ || cx
155+ . tcx
156+ . crate_types ( )
157+ . iter ( )
158+ . any ( |t : & CrateType | matches ! ( t, CrateType :: ProcMacro ) )
159+ {
161160 return ;
162161 }
163162
0 commit comments