@@ -4,6 +4,7 @@ use rustc_hir::def_id::DefId;
44use rustc_hir:: { self as hir, Attribute , find_attr} ;
55use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
66use rustc_middle:: ty:: AssocContainer ;
7+ use rustc_session:: config:: CrateType ;
78use rustc_session:: declare_lint_pass;
89use rustc_span:: Span ;
910
@@ -81,20 +82,20 @@ fn check_missing_inline_attrs(
8182 }
8283}
8384
84- fn is_executable_or_proc_macro ( cx : & LateContext < ' _ > ) -> bool {
85- use rustc_session:: config:: CrateType ;
86-
87- cx. tcx
88- . crate_types ( )
89- . iter ( )
90- . any ( |t : & CrateType | matches ! ( t, CrateType :: Executable | CrateType :: ProcMacro ) )
91- }
92-
9385declare_lint_pass ! ( MissingInline => [ MISSING_INLINE_IN_PUBLIC_ITEMS ] ) ;
9486
9587impl < ' tcx > LateLintPass < ' tcx > for MissingInline {
9688 fn check_item ( & mut self , cx : & LateContext < ' tcx > , it : & ' tcx hir:: Item < ' _ > ) {
97- if it. span . in_external_macro ( cx. sess ( ) . source_map ( ) ) || is_executable_or_proc_macro ( cx) {
89+ if it. span . in_external_macro ( cx. sess ( ) . source_map ( ) ) {
90+ return ;
91+ }
92+
93+ if cx
94+ . tcx
95+ . crate_types ( )
96+ . iter ( )
97+ . any ( |t : & CrateType | matches ! ( t, CrateType :: ProcMacro ) )
98+ {
9899 return ;
99100 }
100101
@@ -149,7 +150,13 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
149150 }
150151
151152 fn check_impl_item ( & mut self , cx : & LateContext < ' tcx > , impl_item : & ' tcx hir:: ImplItem < ' _ > ) {
152- 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+ {
153160 return ;
154161 }
155162
0 commit comments