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