diff --git a/tests/ui/abi/anon-extern-mod.rs b/tests/ui/abi/anon-extern-mod.rs index a424f93f637c9..bb3739bc4afab 100644 --- a/tests/ui/abi/anon-extern-mod.rs +++ b/tests/ui/abi/anon-extern-mod.rs @@ -1,13 +1,9 @@ //@ run-pass //@ pretty-expanded FIXME #23616 -#![feature(rustc_private)] - -extern crate libc; - #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - fn rust_get_test_int() -> libc::intptr_t; + fn rust_get_test_int() -> isize; } pub fn main() { diff --git a/tests/ui/abi/c-stack-as-value.rs b/tests/ui/abi/c-stack-as-value.rs index 6ea2051b05b3e..401bc132b6e77 100644 --- a/tests/ui/abi/c-stack-as-value.rs +++ b/tests/ui/abi/c-stack-as-value.rs @@ -1,14 +1,10 @@ //@ run-pass //@ pretty-expanded FIXME #23616 -#![feature(rustc_private)] - mod rustrt { - extern crate libc; - #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } } diff --git a/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs b/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs index 5cbf8093c5c3c..559c40546a8a5 100644 --- a/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs +++ b/tests/ui/abi/cross-crate/auxiliary/anon-extern-mod-cross-crate-1.rs @@ -1,9 +1,6 @@ #![crate_name = "anonexternmod"] -#![feature(rustc_private)] - -extern crate libc; #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } diff --git a/tests/ui/abi/foreign/auxiliary/foreign_lib.rs b/tests/ui/abi/foreign/auxiliary/foreign_lib.rs index 3c649b778bd1a..74a95b96e9fc4 100644 --- a/tests/ui/abi/foreign/auxiliary/foreign_lib.rs +++ b/tests/ui/abi/foreign/auxiliary/foreign_lib.rs @@ -1,28 +1,28 @@ #![crate_name = "foreign_lib"] -#![feature(rustc_private)] pub mod rustrt { - extern crate libc; - #[link(name = "rust_test_helpers", kind = "static")] extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } } pub mod rustrt2 { - extern crate libc; - extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } } pub mod rustrt3 { - // Different type, but same ABI (on all supported platforms). - // Ensures that we don't ICE or trigger LLVM asserts when - // importing the same symbol under different types. - // See https://github.com/rust-lang/rust/issues/32740. + // The point of this test is to ensure that we don't ICE or trigger LLVM asserts when importing + // the same symbol with different types. This is not really possible to test portably; there is + // no different signature we can come up with that is different to LLVM but which for sure has + // the same behavior on all platforms. The signed-ness of integers is ignored by LLVM as well + // as pointee types. So the only ways to make our signatures differ are to use + // differently-sized integers which is definitely an ABI mismatch, or to rely on pointers and + // isize/usize having the same ABI, which is wrong on CHERI and probably other niche platforms. + // If this test causes you trouble, please file an issue. + // See https://github.com/rust-lang/rust/issues/32740 for the bug that prompted this test. extern "C" { pub fn rust_get_test_int() -> *const u8; } @@ -32,6 +32,6 @@ pub fn local_uses() { unsafe { let x = rustrt::rust_get_test_int(); assert_eq!(x, rustrt2::rust_get_test_int()); - assert_eq!(x as *const _, rustrt3::rust_get_test_int()); + assert_eq!(x as *const u8, rustrt3::rust_get_test_int()); } } diff --git a/tests/ui/abi/foreign/foreign-dupe.rs b/tests/ui/abi/foreign/foreign-dupe.rs index 1b6df0892c70f..3473d436cb483 100644 --- a/tests/ui/abi/foreign/foreign-dupe.rs +++ b/tests/ui/abi/foreign/foreign-dupe.rs @@ -4,13 +4,12 @@ // Check that we can still call duplicated extern (imported) functions // which were declared in another crate. See issues #32740 and #32783. - extern crate foreign_lib; pub fn main() { unsafe { let x = foreign_lib::rustrt::rust_get_test_int(); assert_eq!(x, foreign_lib::rustrt2::rust_get_test_int()); - assert_eq!(x as *const _, foreign_lib::rustrt3::rust_get_test_int()); + assert_eq!(x as *const u8, foreign_lib::rustrt3::rust_get_test_int()); } } diff --git a/tests/ui/abi/foreign/foreign-no-abi.rs b/tests/ui/abi/foreign/foreign-no-abi.rs deleted file mode 100644 index 4ac47df29a710..0000000000000 --- a/tests/ui/abi/foreign/foreign-no-abi.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass -// ABI is cdecl by default - -//@ pretty-expanded FIXME #23616 - -#![feature(rustc_private)] - -mod rustrt { - extern crate libc; - - #[link(name = "rust_test_helpers", kind = "static")] - extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; - } -} - -pub fn main() { - unsafe { - rustrt::rust_get_test_int(); - } -} diff --git a/tests/ui/attributes/item-attributes.rs b/tests/ui/attributes/item-attributes.rs index 7fe7fdd97584e..daab1bccb2c4d 100644 --- a/tests/ui/attributes/item-attributes.rs +++ b/tests/ui/attributes/item-attributes.rs @@ -148,7 +148,7 @@ mod test_foreign_items { #![rustc_dummy] #[rustc_dummy] - fn rust_get_test_int() -> u32; + fn rust_get_test_int() -> isize; } } } diff --git a/tests/ui/extern/issue-1251.rs b/tests/ui/extern/issue-1251.rs index da2b8be7bc1f3..5581bddaddc16 100644 --- a/tests/ui/extern/issue-1251.rs +++ b/tests/ui/extern/issue-1251.rs @@ -2,13 +2,10 @@ #![allow(unused_attributes)] #![allow(dead_code)] //@ pretty-expanded FIXME #23616 -#![feature(rustc_private)] mod rustrt { - extern crate libc; - extern "C" { - pub fn rust_get_test_int() -> libc::intptr_t; + pub fn rust_get_test_int() -> isize; } }