@@ -2678,6 +2678,25 @@ fn check_method(ccx: @crate_ctxt, method: @ast::method) {
2678
2678
check_fn ( ccx, ast:: proto_bare, method. decl , method. body , method. id , none) ;
2679
2679
}
2680
2680
2681
+ fn check_native_fn ( ccx : @crate_ctxt , decl : ast:: fn_decl ) {
2682
+ let tys = vec:: map ( decl. inputs ) { |a| a. ty } ;
2683
+ for ty in ( tys + [ decl. output ] ) {
2684
+ alt ty. node {
2685
+ ast:: ty_int ( ast:: ty_i. ) {
2686
+ ccx . tcx . sess . span_warn (
2687
+ ty. span , "found rust type `int` in native module, while " +
2688
+ "ctypes::c_int or ctypes::long should be used" ) ;
2689
+ }
2690
+ ast:: ty_uint ( ast:: ty_u. ) {
2691
+ ccx . tcx . sess . span_warn (
2692
+ ty. span , "found rust type `uint` in native module, while " +
2693
+ "ctypes::c_uint or ctypes::ulong should be used" ) ;
2694
+ }
2695
+ _ { }
2696
+ }
2697
+ }
2698
+ }
2699
+
2681
2700
fn check_item( ccx: @crate_ctxt , it : @ast:: item ) {
2682
2701
alt it. node {
2683
2702
ast:: item_const ( _, e) { check_const ( ccx, it. span , e, it. id ) ; }
@@ -2688,6 +2707,16 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
2688
2707
ast:: item_res ( decl, tps, body, dtor_id, _) {
2689
2708
check_fn ( ccx, ast:: proto_bare, decl, body, dtor_id, none) ;
2690
2709
}
2710
+ ast:: item_native_mod ( nmod) {
2711
+ for ni in nmod. items {
2712
+ alt ni. node {
2713
+ ast:: native_item_fn ( decl, tps) {
2714
+ check_native_fn ( ccx, decl) ;
2715
+ }
2716
+ _ { }
2717
+ }
2718
+ }
2719
+ }
2691
2720
ast:: item_impl ( tps, _, ty, ms) {
2692
2721
ccx. self_infos += [ self_impl ( ast_ty_to_ty ( ccx. tcx , m_check, ty) ) ] ;
2693
2722
for m in ms { check_method ( ccx, m) ; }
0 commit comments