@@ -966,26 +966,39 @@ declare_lint! {
966
966
"const items will not have their symbols exported"
967
967
}
968
968
969
+ declare_lint ! {
970
+ NO_MANGLE_GENERIC_ITEMS ,
971
+ Warn ,
972
+ "generic items must be mangled"
973
+ }
974
+
969
975
#[ derive( Copy , Clone ) ]
970
976
pub struct InvalidNoMangleItems ;
971
977
972
978
impl LintPass for InvalidNoMangleItems {
973
979
fn get_lints ( & self ) -> LintArray {
974
980
lint_array ! ( PRIVATE_NO_MANGLE_FNS ,
975
981
PRIVATE_NO_MANGLE_STATICS ,
976
- NO_MANGLE_CONST_ITEMS )
982
+ NO_MANGLE_CONST_ITEMS ,
983
+ NO_MANGLE_GENERIC_ITEMS )
977
984
}
978
985
}
979
986
980
987
impl LateLintPass for InvalidNoMangleItems {
981
988
fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
982
989
match it. node {
983
- hir:: ItemFn ( ..) => {
984
- if attr:: contains_name ( & it. attrs , "no_mangle" ) &&
985
- !cx. access_levels . is_reachable ( it. id ) {
986
- let msg = format ! ( "function {} is marked #[no_mangle], but not exported" ,
987
- it. name) ;
988
- cx. span_lint ( PRIVATE_NO_MANGLE_FNS , it. span , & msg) ;
990
+ hir:: ItemFn ( _, _, _, _, ref generics, _) => {
991
+ if attr:: contains_name ( & it. attrs , "no_mangle" ) {
992
+ if !cx. access_levels . is_reachable ( it. id ) {
993
+ let msg = format ! ( "function {} is marked #[no_mangle], but not exported" ,
994
+ it. name) ;
995
+ cx. span_lint ( PRIVATE_NO_MANGLE_FNS , it. span , & msg) ;
996
+ }
997
+ if generics. is_parameterized ( ) {
998
+ cx. span_lint ( NO_MANGLE_GENERIC_ITEMS ,
999
+ it. span ,
1000
+ "generic functions must be mangled" ) ;
1001
+ }
989
1002
}
990
1003
} ,
991
1004
hir:: ItemStatic ( ..) => {
0 commit comments