File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -2036,6 +2036,35 @@ impl LintPass for HardwiredLints {
20362036 }
20372037}
20382038
2039+ declare_lint ! {
2040+ PRIVATE_NO_MANGLE_FNS ,
2041+ Warn ,
2042+ "functions marked #[no_mangle] should be exported"
2043+ }
2044+
2045+ #[ derive( Copy ) ]
2046+ pub struct PrivateNoMangleFns ;
2047+
2048+ impl LintPass for PrivateNoMangleFns {
2049+ fn get_lints ( & self ) -> LintArray {
2050+ lint_array ! ( PRIVATE_NO_MANGLE_FNS )
2051+ }
2052+
2053+ fn check_item ( & mut self , cx : & Context , it : & ast:: Item ) {
2054+ match it. node {
2055+ ast:: ItemFn ( ..) => {
2056+ if attr:: contains_name ( it. attrs . as_slice ( ) , "no_mangle" ) &&
2057+ !cx. exported_items . contains ( & it. id ) {
2058+ let msg = format ! ( "function {} is marked #[no_mangle], but not exported" ,
2059+ it. ident) ;
2060+ cx. span_lint ( PRIVATE_NO_MANGLE_FNS , it. span , msg. as_slice ( ) ) ;
2061+ }
2062+ } ,
2063+ _ => { } ,
2064+ }
2065+ }
2066+ }
2067+
20392068/// Forbids using the `#[feature(...)]` attribute
20402069#[ derive( Copy ) ]
20412070pub struct UnstableFeatures ;
Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ impl LintStore {
213213 UnstableFeatures ,
214214 Stability ,
215215 UnconditionalRecursion ,
216+ PrivateNoMangleFns ,
216217 ) ;
217218
218219 add_builtin_with_new ! ( sess,
You can’t perform that action at this time.
0 commit comments