summaryrefslogtreecommitdiffstats
path: root/tests/ui/abi
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/ui/abi/abi-typo-unstable.stderr2
-rw-r--r--tests/ui/abi/arm-unadjusted-intrinsic.rs54
-rw-r--r--tests/ui/abi/compatibility.rs45
-rw-r--r--tests/ui/abi/issue-94223.rs8
-rw-r--r--tests/ui/abi/riscv-discoverability-guidance.rs4
-rw-r--r--tests/ui/abi/stack-probes-lto.rs4
-rw-r--r--tests/ui/abi/stack-probes.rs4
-rw-r--r--tests/ui/abi/unsized-args-in-c-abi-issues-94223-115845.rs30
-rw-r--r--tests/ui/abi/variadic-ffi.rs5
9 files changed, 131 insertions, 25 deletions
diff --git a/tests/ui/abi/abi-typo-unstable.stderr b/tests/ui/abi/abi-typo-unstable.stderr
index 3b346e002..d31cc2a89 100644
--- a/tests/ui/abi/abi-typo-unstable.stderr
+++ b/tests/ui/abi/abi-typo-unstable.stderr
@@ -6,6 +6,6 @@ LL | extern "rust-intrinsec" fn rust_intrinsic() {}
|
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions.
-error: aborting due to previous error
+error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0703`.
diff --git a/tests/ui/abi/arm-unadjusted-intrinsic.rs b/tests/ui/abi/arm-unadjusted-intrinsic.rs
new file mode 100644
index 000000000..33ea79275
--- /dev/null
+++ b/tests/ui/abi/arm-unadjusted-intrinsic.rs
@@ -0,0 +1,54 @@
+// build-pass
+// revisions: arm
+//[arm] compile-flags: --target arm-unknown-linux-gnueabi
+//[arm] needs-llvm-components: arm
+// revisions: aarch64
+//[aarch64] compile-flags: --target aarch64-unknown-linux-gnu
+//[aarch64] needs-llvm-components: aarch64
+#![feature(
+ no_core, lang_items, link_llvm_intrinsics,
+ abi_unadjusted, repr_simd, arm_target_feature,
+)]
+#![no_std]
+#![no_core]
+#![crate_type = "lib"]
+#![allow(non_camel_case_types)]
+
+/// To work cross-target this test must be no_core.
+/// This little prelude supplies what we need.
+#[lang = "sized"]
+pub trait Sized {}
+
+#[lang = "copy"]
+pub trait Copy: Sized {}
+impl Copy for i8 {}
+impl<T: ?Sized> Copy for *const T {}
+impl<T: ?Sized> Copy for *mut T {}
+
+
+// Regression test for https://github.com/rust-lang/rust/issues/118124.
+
+#[repr(simd)]
+pub struct int8x16_t(
+ pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8,
+ pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8,
+ pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8,
+ pub(crate) i8, pub(crate) i8, pub(crate) i8, pub(crate) i8,
+);
+impl Copy for int8x16_t {}
+
+#[repr(C)]
+pub struct int8x16x4_t(pub int8x16_t, pub int8x16_t, pub int8x16_t, pub int8x16_t);
+impl Copy for int8x16x4_t {}
+
+#[target_feature(enable = "neon")]
+#[cfg_attr(target_arch = "arm", target_feature(enable = "v7"))]
+pub unsafe fn vld1q_s8_x4(a: *const i8) -> int8x16x4_t {
+ #[allow(improper_ctypes)]
+ extern "unadjusted" {
+ #[cfg_attr(target_arch = "arm", link_name = "llvm.arm.neon.vld1x4.v16i8.p0i8")]
+ #[cfg_attr(target_arch = "aarch64", link_name = "llvm.aarch64.neon.ld1x4.v16i8.p0i8")]
+ fn vld1q_s8_x4_(a: *const i8) -> int8x16x4_t;
+ }
+ vld1q_s8_x4_(a)
+}
diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs
index 0cdf22971..c6bba7186 100644
--- a/tests/ui/abi/compatibility.rs
+++ b/tests/ui/abi/compatibility.rs
@@ -1,5 +1,14 @@
// check-pass
// revisions: host
+// revisions: i686
+//[i686] compile-flags: --target i686-unknown-linux-gnu
+//[i686] needs-llvm-components: x86
+// revisions: x86-64
+//[x86-64] compile-flags: --target x86_64-unknown-linux-gnu
+//[x86-64] needs-llvm-components: x86
+// revisions: x86-64-win
+//[x86-64-win] compile-flags: --target x86_64-pc-windows-msvc
+//[x86-64-win] needs-llvm-components: x86
// revisions: arm
//[arm] compile-flags: --target arm-unknown-linux-gnueabi
//[arm] needs-llvm-components: arm
@@ -37,9 +46,23 @@
// revisions: wasi
//[wasi] compile-flags: --target wasm32-wasi
//[wasi] needs-llvm-components: webassembly
-// revisions: nvptx64
-//[nvptx64] compile-flags: --target nvptx64-nvidia-cuda
-//[nvptx64] needs-llvm-components: nvptx
+// revisions: bpf
+//[bpf] compile-flags: --target bpfeb-unknown-none
+//[bpf] needs-llvm-components: bpf
+// revisions: m68k
+//[m68k] compile-flags: --target m68k-unknown-linux-gnu
+//[m68k] needs-llvm-components: m68k
+// FIXME: disabled on nvptx64 since the target ABI fails the sanity check
+// see https://github.com/rust-lang/rust/issues/117480
+/* revisions: nvptx64
+ [nvptx64] compile-flags: --target nvptx64-nvidia-cuda
+ [nvptx64] needs-llvm-components: nvptx
+*/
+// FIXME: disabled since it fails on CI saying the csky component is missing
+/* revisions: csky
+ [csky] compile-flags: --target csky-unknown-linux-gnuabiv2
+ [csky] needs-llvm-components: csky
+*/
#![feature(rustc_attrs, unsized_fn_params, transparent_unions)]
#![cfg_attr(not(host), feature(no_core, lang_items), no_std, no_core)]
#![allow(unused, improper_ctypes_definitions, internal_features)]
@@ -231,8 +254,7 @@ macro_rules! test_abi_compatible {
};
}
-// Compatibility of pointers is probably de-facto guaranteed,
-// but that does not seem to be documented.
+// Compatibility of pointers.
test_abi_compatible!(ptr_mut, *const i32, *mut i32);
test_abi_compatible!(ptr_pointee, *const i32, *const Vec<i32>);
test_abi_compatible!(ref_mut, &i32, &mut i32);
@@ -241,14 +263,22 @@ test_abi_compatible!(box_ptr, Box<i32>, *const i32);
test_abi_compatible!(nonnull_ptr, NonNull<i32>, *const i32);
test_abi_compatible!(fn_fn, fn(), fn(i32) -> i32);
-// Some further guarantees we will likely (have to) make.
+// Compatibility of integer types.
+test_abi_compatible!(char_uint, char, u32);
+#[cfg(target_pointer_width = "32")]
+test_abi_compatible!(isize_int, isize, i32);
+#[cfg(target_pointer_width = "64")]
+test_abi_compatible!(isize_int, isize, i64);
+
+// Compatibility of 1-ZST.
test_abi_compatible!(zst_unit, Zst, ());
#[cfg(not(any(target_arch = "sparc64")))]
test_abi_compatible!(zst_array, Zst, [u8; 0]);
test_abi_compatible!(nonzero_int, NonZeroI32, i32);
// `DispatchFromDyn` relies on ABI compatibility.
-// This is interesting since these types are not `repr(transparent)`.
+// This is interesting since these types are not `repr(transparent)`. So this is not part of our
+// public ABI guarantees, but is relied on by the compiler.
test_abi_compatible!(rc, Rc<i32>, *mut i32);
test_abi_compatible!(arc, Arc<i32>, *mut i32);
@@ -324,6 +354,7 @@ mod unsized_ {
use super::*;
test_transparent_unsized!(str_, str);
test_transparent_unsized!(slice, [u8]);
+ test_transparent_unsized!(slice_with_prefix, (usize, [u8]));
test_transparent_unsized!(dyn_trait, dyn Any);
}
diff --git a/tests/ui/abi/issue-94223.rs b/tests/ui/abi/issue-94223.rs
deleted file mode 100644
index 79d6b9403..000000000
--- a/tests/ui/abi/issue-94223.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-// check-pass
-#![allow(improper_ctypes_definitions)]
-#![crate_type = "lib"]
-
-// Check that computing the fn abi for `bad`, with a external ABI fn ptr that is not FFI-safe, does
-// not ICE.
-
-pub fn bad(f: extern "C" fn([u8])) {}
diff --git a/tests/ui/abi/riscv-discoverability-guidance.rs b/tests/ui/abi/riscv-discoverability-guidance.rs
index f57fcd604..361ed8f3d 100644
--- a/tests/ui/abi/riscv-discoverability-guidance.rs
+++ b/tests/ui/abi/riscv-discoverability-guidance.rs
@@ -2,9 +2,9 @@
// revisions: riscv32 riscv64
//
// [riscv32] needs-llvm-components: riscv
-// [riscv32] compile-flags: --target=riscv32i-unknown-none-elf -C target-feature=-unaligned-scalar-mem --crate-type=rlib
+// [riscv32] compile-flags: --target=riscv32i-unknown-none-elf -C target-feature=-fast-unaligned-access --crate-type=rlib
// [riscv64] needs-llvm-components: riscv
-// [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf -C target-feature=-unaligned-scalar-mem --crate-type=rlib
+// [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf -C target-feature=-fast-unaligned-access --crate-type=rlib
#![no_core]
#![feature(
no_core,
diff --git a/tests/ui/abi/stack-probes-lto.rs b/tests/ui/abi/stack-probes-lto.rs
index 7282d0970..fb4786717 100644
--- a/tests/ui/abi/stack-probes-lto.rs
+++ b/tests/ui/abi/stack-probes-lto.rs
@@ -1,5 +1,7 @@
-// revisions: x32 x64
+// revisions: aarch64 x32 x64
// run-pass
+//[aarch64] only-aarch64
+//[aarch64] min-llvm-version: 18
//[x32] only-x86
//[x64] only-x86_64
// ignore-sgx no processes
diff --git a/tests/ui/abi/stack-probes.rs b/tests/ui/abi/stack-probes.rs
index 4b8a79a4b..e5c7a1a68 100644
--- a/tests/ui/abi/stack-probes.rs
+++ b/tests/ui/abi/stack-probes.rs
@@ -1,5 +1,7 @@
-// revisions: x32 x64
+// revisions: aarch64 x32 x64
// run-pass
+//[aarch64] only-aarch64
+//[aarch64] min-llvm-version: 18
//[x32] only-x86
//[x64] only-x86_64
// ignore-emscripten no processes
diff --git a/tests/ui/abi/unsized-args-in-c-abi-issues-94223-115845.rs b/tests/ui/abi/unsized-args-in-c-abi-issues-94223-115845.rs
new file mode 100644
index 000000000..a32cc6500
--- /dev/null
+++ b/tests/ui/abi/unsized-args-in-c-abi-issues-94223-115845.rs
@@ -0,0 +1,30 @@
+// check-pass
+#![allow(improper_ctypes_definitions)]
+#![feature(unsized_tuple_coercion)]
+#![feature(unsized_fn_params)]
+#![crate_type = "lib"]
+
+// Check that computing the fn abi for `bad`, with a external ABI fn ptr that is not FFI-safe, does
+// not ICE.
+
+pub fn bad(f: extern "C" fn([u8])) {}
+
+// While these get accepted, they should also not ICE.
+// (If we ever reject them, remove them from this test to ensure the `bad` above
+// is still tested. Do *not* make this a check/build-fail test.)
+
+pub extern "C" fn declare_bad(_x: str) {}
+
+#[no_mangle]
+pub extern "system" fn declare_more_bad(f: dyn FnOnce()) {
+}
+
+fn make_bad() -> extern "C" fn(([u8],)) {
+ todo!()
+}
+
+pub fn call_bad() {
+ let f = make_bad();
+ let slice: Box<([u8],)> = Box::new(([1; 8],));
+ f(*slice);
+}
diff --git a/tests/ui/abi/variadic-ffi.rs b/tests/ui/abi/variadic-ffi.rs
index a952ea077..186217700 100644
--- a/tests/ui/abi/variadic-ffi.rs
+++ b/tests/ui/abi/variadic-ffi.rs
@@ -8,11 +8,6 @@ use std::ffi::VaList;
extern "C" {
fn rust_interesting_average(_: u64, ...) -> f64;
- // FIXME: we need to disable this lint for `VaList`,
- // since it contains a `MaybeUninit<i32>` on the asmjs target,
- // and this type isn't FFI-safe. This is OK for now,
- // since the type is layout-compatible with `i32`.
- #[cfg_attr(target_arch = "asmjs", allow(improper_ctypes))]
fn rust_valist_interesting_average(_: u64, _: VaList) -> f64;
}