@@ -83,6 +83,17 @@ impl MissingInline {
83
83
}
84
84
}
85
85
86
+ fn is_executable < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > ) -> bool {
87
+ use rustc:: session:: config:: CrateType ;
88
+
89
+ cx. tcx . sess . crate_types . get ( ) . iter ( ) . any ( |t : & CrateType | {
90
+ match t {
91
+ CrateType :: CrateTypeExecutable => true ,
92
+ _ => false ,
93
+ }
94
+ } )
95
+ }
96
+
86
97
impl LintPass for MissingInline {
87
98
fn get_lints ( & self ) -> LintArray {
88
99
lint_array ! [ MISSING_INLINE_IN_PUBLIC_ITEMS ]
@@ -91,19 +102,15 @@ impl LintPass for MissingInline {
91
102
92
103
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for MissingInline {
93
104
fn check_item ( & mut self , cx : & LateContext < ' a , ' tcx > , it : & ' tcx hir:: Item ) {
105
+ if is_executable ( cx) {
106
+ return ;
107
+ }
108
+
94
109
if !cx. access_levels . is_exported ( it. id ) {
95
110
return ;
96
111
}
97
112
match it. node {
98
113
hir:: ItemFn ( ..) => {
99
- // ignore main()
100
- if it. name == "main" {
101
- let def_id = cx. tcx . hir . local_def_id ( it. id ) ;
102
- let def_key = cx. tcx . hir . def_key ( def_id) ;
103
- if def_key. parent == Some ( hir:: def_id:: CRATE_DEF_INDEX ) {
104
- return ;
105
- }
106
- }
107
114
let desc = "a function" ;
108
115
self . check_missing_inline_attrs ( cx, & it. attrs , it. span , desc) ;
109
116
} ,
@@ -148,6 +155,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingInline {
148
155
149
156
fn check_impl_item ( & mut self , cx : & LateContext < ' a , ' tcx > , impl_item : & ' tcx hir:: ImplItem ) {
150
157
use rustc:: ty:: { TraitContainer , ImplContainer } ;
158
+ if is_executable ( cx) {
159
+ return ;
160
+ }
151
161
152
162
// If the item being implemented is not exported, then we don't need #[inline]
153
163
if !cx. access_levels . is_exported ( impl_item. id ) {
0 commit comments