@@ -971,26 +971,39 @@ declare_lint! {
971
971
"const items will not have their symbols exported"
972
972
}
973
973
974
+ declare_lint ! {
975
+ NO_MANGLE_GENERIC_ITEMS ,
976
+ Warn ,
977
+ "generic items must be mangled"
978
+ }
979
+
974
980
#[ derive( Copy , Clone ) ]
975
981
pub struct InvalidNoMangleItems ;
976
982
977
983
impl LintPass for InvalidNoMangleItems {
978
984
fn get_lints ( & self ) -> LintArray {
979
985
lint_array ! ( PRIVATE_NO_MANGLE_FNS ,
980
986
PRIVATE_NO_MANGLE_STATICS ,
981
- NO_MANGLE_CONST_ITEMS )
987
+ NO_MANGLE_CONST_ITEMS ,
988
+ NO_MANGLE_GENERIC_ITEMS )
982
989
}
983
990
}
984
991
985
992
impl LateLintPass for InvalidNoMangleItems {
986
993
fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
987
994
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
+ }
994
1007
}
995
1008
} ,
996
1009
hir:: ItemStatic ( ..) => {
0 commit comments