@@ -709,40 +709,42 @@ fn check_item_default_methods(cx: &Context, item: @ast::item) {
709709}
710710
711711fn check_item_ctypes ( cx : & Context , it : @ast:: item ) {
712+ fn check_ty ( cx : & Context , ty : @ast:: Ty ) {
713+ match ty. node {
714+ ast:: ty_path( _, _, id) => {
715+ match cx. tcx . def_map . get_copy ( & id) {
716+ ast:: def_prim_ty( ast:: ty_int( ast:: ty_i) ) => {
717+ cx. span_lint ( ctypes, ty. span ,
718+ "found rust type `int` in foreign module, while \
719+ libc::c_int or libc::c_long should be used") ;
720+ }
721+ ast:: def_prim_ty( ast:: ty_uint( ast:: ty_u) ) => {
722+ cx. span_lint ( ctypes, ty. span ,
723+ "found rust type `uint` in foreign module, while \
724+ libc::c_uint or libc::c_ulong should be used") ;
725+ }
726+ _ => ( )
727+ }
728+ }
729+ _ => ( )
730+ }
731+ }
712732
713733 fn check_foreign_fn ( cx : & Context , decl : & ast:: fn_decl ) {
714734 let tys = vec:: map ( decl. inputs , |a| a. ty ) ;
715735 for vec:: each( vec:: append_one( tys, decl. output) ) |ty| {
716- match ty. node {
717- ast:: ty_path( _, _, id) => {
718- match cx. tcx . def_map . get_copy ( & id) {
719- ast:: def_prim_ty( ast:: ty_int( ast:: ty_i) ) => {
720- cx. span_lint ( ctypes, ty. span ,
721- "found rust type `int` in foreign module, while \
722- libc::c_int or libc::c_long should be used") ;
723- }
724- ast:: def_prim_ty( ast:: ty_uint( ast:: ty_u) ) => {
725- cx. span_lint ( ctypes, ty. span ,
726- "found rust type `uint` in foreign module, while \
727- libc::c_uint or libc::c_ulong should be used") ;
728- }
729- _ => ( )
730- }
731- }
732- _ => ( )
733- }
736+ check_ty( cx, * ty) ;
734737 }
735738 }
736739
737740 match it. node {
738741 ast:: item_foreign_mod( ref nmod) if !nmod. abis . is_intrinsic ( ) => {
739742 for nmod. items. iter ( ) . advance |ni| {
740743 match ni. node {
741- ast : : foreign_item_fn( ref decl, _, _) => {
742- check_foreign_fn( cx, decl) ;
743- }
744- // FIXME #4622: Not implemented.
745- ast:: foreign_item_const( * ) => { }
744+ ast : : foreign_item_fn( ref decl, _, _) => {
745+ check_foreign_fn( cx, decl) ;
746+ }
747+ ast:: foreign_item_static( t, _) => { check_ty( cx, t) ; }
746748 }
747749 }
748750 }
0 commit comments