@@ -709,40 +709,42 @@ fn check_item_default_methods(cx: &Context, item: @ast::item) {
709
709
}
710
710
711
711
fn 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
+ }
712
732
713
733
fn check_foreign_fn ( cx : & Context , decl : & ast:: fn_decl ) {
714
734
let tys = vec:: map ( decl. inputs , |a| a. ty ) ;
715
735
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) ;
734
737
}
735
738
}
736
739
737
740
match it. node {
738
741
ast:: item_foreign_mod( ref nmod) if !nmod. abis . is_intrinsic ( ) => {
739
742
for nmod. items. iter ( ) . advance |ni| {
740
743
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) ; }
746
748
}
747
749
}
748
750
}
0 commit comments