@@ -971,26 +971,39 @@ declare_lint! {
971971 "const items will not have their symbols exported"
972972}
973973
974+ declare_lint ! {
975+ NO_MANGLE_GENERIC_ITEMS ,
976+ Warn ,
977+ "generic items must be mangled"
978+ }
979+
974980#[ derive( Copy , Clone ) ]
975981pub struct InvalidNoMangleItems ;
976982
977983impl LintPass for InvalidNoMangleItems {
978984 fn get_lints ( & self ) -> LintArray {
979985 lint_array ! ( PRIVATE_NO_MANGLE_FNS ,
980986 PRIVATE_NO_MANGLE_STATICS ,
981- NO_MANGLE_CONST_ITEMS )
987+ NO_MANGLE_CONST_ITEMS ,
988+ NO_MANGLE_GENERIC_ITEMS )
982989 }
983990}
984991
985992impl LateLintPass for InvalidNoMangleItems {
986993 fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
987994 match it. node {
988- hir:: ItemFn ( ..) => {
989- if attr:: contains_name ( & it. attrs , "no_mangle" ) &&
990- !cx. access_levels . is_reachable ( it. id ) {
991- let msg = format ! ( "function {} is marked #[no_mangle], but not exported" ,
992- it. name) ;
993- cx. span_lint ( PRIVATE_NO_MANGLE_FNS , it. span , & msg) ;
995+ hir:: ItemFn ( _, _, _, _, ref generics, _) => {
996+ if attr:: contains_name ( & it. attrs , "no_mangle" ) {
997+ if !cx. access_levels . is_reachable ( it. id ) {
998+ let msg = format ! ( "function {} is marked #[no_mangle], but not exported" ,
999+ it. name) ;
1000+ cx. span_lint ( PRIVATE_NO_MANGLE_FNS , it. span , & msg) ;
1001+ }
1002+ if generics. is_parameterized ( ) {
1003+ cx. span_lint ( NO_MANGLE_GENERIC_ITEMS ,
1004+ it. span ,
1005+ "generic functions must be mangled" ) ;
1006+ }
9941007 }
9951008 } ,
9961009 hir:: ItemStatic ( ..) => {
0 commit comments