@@ -966,26 +966,39 @@ declare_lint! {
966966 "const items will not have their symbols exported"
967967}
968968
969+ declare_lint ! {
970+ NO_MANGLE_GENERIC_ITEMS ,
971+ Warn ,
972+ "generic items must be mangled"
973+ }
974+
969975#[ derive( Copy , Clone ) ]
970976pub struct InvalidNoMangleItems ;
971977
972978impl LintPass for InvalidNoMangleItems {
973979 fn get_lints ( & self ) -> LintArray {
974980 lint_array ! ( PRIVATE_NO_MANGLE_FNS ,
975981 PRIVATE_NO_MANGLE_STATICS ,
976- NO_MANGLE_CONST_ITEMS )
982+ NO_MANGLE_CONST_ITEMS ,
983+ NO_MANGLE_GENERIC_ITEMS )
977984 }
978985}
979986
980987impl LateLintPass for InvalidNoMangleItems {
981988 fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
982989 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+ }
9891002 }
9901003 } ,
9911004 hir:: ItemStatic ( ..) => {
0 commit comments