about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-10-06 01:26:13 +0000
committerbors <bors@rust-lang.org>2015-10-06 01:26:13 +0000
commit88b6a5063df6e52921cbbb99940a38bebdcd6749 (patch)
tree0edf69160140765be3273d47c13eca15cabfc81f
parent32a8567ea4ded47ac4cfd39bc808bb8d6f2e119c (diff)
parentbd6758a2b5781599d1e4eb48a897616d1b0cf8a0 (diff)
downloadrust-88b6a5063df6e52921cbbb99940a38bebdcd6749.tar.gz
rust-88b6a5063df6e52921cbbb99940a38bebdcd6749.zip
Auto merge of #28779 - alexcrichton:ffi-isize-usize, r=nrc
This lint warning was originally intended to help against misuse of the old Rust
`int` and `uint` types in FFI bindings where the Rust `int` was not equal to the
C `int`. This confusion no longer exists (as Rust's types are now `isize` and
`usize`), and as a result the need for this lint has become much less over time.

Additionally, starting with [the RFC for libc][rfc] it's likely that `isize` and
`usize` will be quite common in FFI bindings (e.g. they're the definition of
`size_t` and `ssize_t` on many platforms).

[rfc]: https://github.com/rust-lang/rfcs/pull/1291

This commit disables these lints to instead consider `isize` and `usize` valid
types to have in FFI signatures.
-rw-r--r--src/librustc_lint/types.rs8
-rw-r--r--src/test/compile-fail/issue-16250.rs4
-rw-r--r--src/test/compile-fail/lint-ctypes.rs9
-rw-r--r--src/test/run-pass/foreign-int-types.rs (renamed from src/test/compile-fail/warn-foreign-int-types.rs)5
4 files changed, 10 insertions, 16 deletions
diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs
index cf6cc9bb7ce..c95d8b7bf3e 100644
--- a/src/librustc_lint/types.rs
+++ b/src/librustc_lint/types.rs
@@ -497,14 +497,6 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
                 FfiSafe
             }
 
-            ty::TyInt(ast::TyIs) => {
-                FfiUnsafe("found Rust type `isize` in foreign module, while \
-                          `libc::c_int` or `libc::c_long` should be used")
-            }
-            ty::TyUint(ast::TyUs) => {
-                FfiUnsafe("found Rust type `usize` in foreign module, while \
-                          `libc::c_uint` or `libc::c_ulong` should be used")
-            }
             ty::TyChar => {
                 FfiUnsafe("found Rust type `char` in foreign module, while \
                            `u32` or `libc::wchar_t` should be used")
diff --git a/src/test/compile-fail/issue-16250.rs b/src/test/compile-fail/issue-16250.rs
index b5aa3568122..288fe4a9abb 100644
--- a/src/test/compile-fail/issue-16250.rs
+++ b/src/test/compile-fail/issue-16250.rs
@@ -10,8 +10,10 @@
 
 #![deny(warnings)]
 
+pub struct Foo;
+
 extern {
-    pub fn foo(x: (isize)); //~ ERROR found Rust type `isize` in foreign module
+    pub fn foo(x: (Foo)); //~ ERROR found struct without
 }
 
 fn main() {
diff --git a/src/test/compile-fail/lint-ctypes.rs b/src/test/compile-fail/lint-ctypes.rs
index 4daba86679d..5c49098d870 100644
--- a/src/test/compile-fail/lint-ctypes.rs
+++ b/src/test/compile-fail/lint-ctypes.rs
@@ -27,12 +27,11 @@ pub struct ZeroSize;
 pub type RustFn = fn();
 pub type RustBadRet = extern fn() -> Box<u32>;
 pub type CVoidRet = ();
+pub struct Foo;
 
 extern {
-    pub fn bare_type1(size: isize); //~ ERROR: found Rust type
-    pub fn bare_type2(size: usize); //~ ERROR: found Rust type
-    pub fn ptr_type1(size: *const isize); //~ ERROR: found Rust type
-    pub fn ptr_type2(size: *const usize); //~ ERROR: found Rust type
+    pub fn ptr_type1(size: *const Foo); //~ ERROR: found struct without
+    pub fn ptr_type2(size: *const Foo); //~ ERROR: found struct without
     pub fn slice_type(p: &[u32]); //~ ERROR: found Rust slice type
     pub fn str_type(p: &str); //~ ERROR: found Rust type
     pub fn box_type(p: Box<u32>); //~ ERROR found Rust type
@@ -55,6 +54,8 @@ extern {
     pub fn good8(fptr: extern fn() -> !);
     pub fn good9() -> ();
     pub fn good10() -> CVoidRet;
+    pub fn good11(size: isize);
+    pub fn good12(size: usize);
 }
 
 fn main() {
diff --git a/src/test/compile-fail/warn-foreign-int-types.rs b/src/test/run-pass/foreign-int-types.rs
index b77f25a0a34..5ea0ef6c7ba 100644
--- a/src/test/compile-fail/warn-foreign-int-types.rs
+++ b/src/test/run-pass/foreign-int-types.rs
@@ -13,9 +13,8 @@
 
 mod xx {
     extern {
-        pub fn strlen(str: *const u8) -> usize; //~ ERROR found Rust type `usize`
-        pub fn foo(x: isize, y: usize); //~ ERROR found Rust type `isize`
-        //~^ ERROR found Rust type `usize`
+        pub fn strlen(str: *const u8) -> usize;
+        pub fn foo(x: isize, y: usize);
     }
 }