]> git.lizzy.rs Git - rust.git/commitdiff
Expand ctypes warnings to warn about *int/*uint
authorAlex Crichton <alex@alexcrichton.com>
Fri, 12 Jul 2013 02:40:53 +0000 (19:40 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 12 Jul 2013 02:45:25 +0000 (19:45 -0700)
Also ends up fixing one case in libstd

src/librustc/middle/lint.rs
src/libstd/unstable/global.rs
src/rt/rust_builtin.cpp
src/rt/rust_kernel.h
src/test/compile-fail/lint-ctypes.rs [new file with mode: 0644]
src/test/compile-fail/warn-ctypes-err-attr.rs [deleted file]
src/test/compile-fail/warn-ctypes.rs [deleted file]

index 0fc19ffd78e521ab8694a0c743f5822cc5b725b2..5b85e404797cba880fcba7be4531f16f8899ae46 100644 (file)
@@ -741,6 +741,7 @@ fn check_ty(cx: &Context, ty: &ast::Ty) {
                     _ => ()
                 }
             }
+            ast::ty_ptr(ref mt) => { check_ty(cx, mt.ty) }
             _ => ()
         }
     }
index 285a8114cc24032e287e8264a753ee746f074ed1..af28879f73971c9a2fbed1ce880e361b4b142f6e 100644 (file)
@@ -28,7 +28,7 @@
 use cast::{transmute};
 use clone::Clone;
 use kinds::Send;
-use libc::{c_void};
+use libc::{c_void, intptr_t};
 use option::{Option, Some, None};
 use ops::Drop;
 use unstable::sync::{Exclusive, exclusive};
@@ -228,7 +228,7 @@ fn key_ptr<T:Send>(key: GlobalDataKey<T>) -> uint {
 }
 
 extern {
-    fn rust_get_global_data_ptr() -> *mut int;
+    fn rust_get_global_data_ptr() -> *mut intptr_t;
 }
 
 #[test]
index 17f36e810cd1ab70092ae42eb9066e91840ff448..e6a3ad4394a21f4684fcab56b97510beca1c7ebf 100644 (file)
@@ -774,7 +774,7 @@ rust_register_exit_function(spawn_fn runner, fn_env_pair *f) {
     task->kernel->register_exit_function(runner, f);
 }
 
-extern "C" void *
+extern "C" intptr_t*
 rust_get_global_data_ptr() {
     rust_task *task = rust_get_current_task();
     return &task->kernel->global_data;
index 4976dec149a0273148b8c3eaeaebbeec84b8052e..09f73f9b7d855936b6d2532ec35766990135ef63 100644 (file)
@@ -124,7 +124,7 @@ class rust_kernel {
 
 public:
     struct rust_env *env;
-    uintptr_t global_data;
+    intptr_t global_data;
 
     rust_kernel(rust_env *env);
 
diff --git a/src/test/compile-fail/lint-ctypes.rs b/src/test/compile-fail/lint-ctypes.rs
new file mode 100644 (file)
index 0000000..a0c027b
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#[deny(ctypes)];
+
+use std::libc;
+
+#[nolink]
+extern {
+    pub fn bare_type1(size: int); //~ ERROR: found rust type
+    pub fn bare_type2(size: uint); //~ ERROR: found rust type
+    pub fn ptr_type1(size: *int); //~ ERROR: found rust type
+    pub fn ptr_type2(size: *uint); //~ ERROR: found rust type
+
+    pub fn good1(size: *libc::c_int);
+    pub fn good2(size: *libc::c_uint);
+}
+
+fn main() {
+}
diff --git a/src/test/compile-fail/warn-ctypes-err-attr.rs b/src/test/compile-fail/warn-ctypes-err-attr.rs
deleted file mode 100644 (file)
index adec8dc..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// error-pattern:found rust type
-#[deny(ctypes)];
-
-mod libc {
-    #[nolink]
-    pub extern {
-        pub fn malloc(size: int) -> *u8;
-    }
-}
-
-fn main() {
-}
diff --git a/src/test/compile-fail/warn-ctypes.rs b/src/test/compile-fail/warn-ctypes.rs
deleted file mode 100644 (file)
index 28d21bb..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// compile-flags:-D ctypes
-// error-pattern:found rust type
-mod libc {
-    #[nolink]
-    extern {
-        pub fn malloc(size: int) -> *u8;
-    }
-}
-
-fn main() {
-}