File tree 2 files changed +30
-0
lines changed
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 {
2036
2036
}
2037
2037
}
2038
2038
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
+
2039
2068
/// Forbids using the `#[feature(...)]` attribute
2040
2069
#[ derive( Copy ) ]
2041
2070
pub struct UnstableFeatures ;
Original file line number Diff line number Diff line change @@ -213,6 +213,7 @@ impl LintStore {
213
213
UnstableFeatures ,
214
214
Stability ,
215
215
UnconditionalRecursion ,
216
+ PrivateNoMangleFns ,
216
217
) ;
217
218
218
219
add_builtin_with_new ! ( sess,
You can’t perform that action at this time.
0 commit comments