about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-07-26 22:42:33 -0400
committerGitHub <noreply@github.com>2025-07-26 22:42:33 -0400
commite2c2d1a493e5893b80dc02ae6efd9de9ffefa450 (patch)
tree2d38cb7f205943c536844d5b425fe8d6c6b328d5 /tests/ui
parent85e5100ad44b7ce4001394dc6bc713d97b86c101 (diff)
parentf75595d2cd38e8a0a36ffc18a90fc5b05e290ee3 (diff)
downloadrust-e2c2d1a493e5893b80dc02ae6efd9de9ffefa450.tar.gz
rust-e2c2d1a493e5893b80dc02ae6efd9de9ffefa450.zip
Rollup merge of #144359 - RalfJung:vararg-codegen, r=compiler-errors
add codegen test for variadics

This is a part of https://github.com/rust-lang/rust/pull/144066 that can land without FCP.
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/c-variadic/variadic-ffi-1.rs5
-rw-r--r--tests/ui/c-variadic/variadic-ffi-1.stderr32
-rw-r--r--tests/ui/c-variadic/variadic-ffi-2-arm.rs9
-rw-r--r--tests/ui/c-variadic/variadic-ffi-2.rs28
-rw-r--r--tests/ui/c-variadic/variadic-ffi-2.stderr9
5 files changed, 24 insertions, 59 deletions
diff --git a/tests/ui/c-variadic/variadic-ffi-1.rs b/tests/ui/c-variadic/variadic-ffi-1.rs
index cd8f2a951ef..2baa00a079a 100644
--- a/tests/ui/c-variadic/variadic-ffi-1.rs
+++ b/tests/ui/c-variadic/variadic-ffi-1.rs
@@ -12,6 +12,11 @@ extern "stdcall" {
     //~^ ERROR: C-variadic functions with the "stdcall" calling convention are not supported
 }
 
+fn baz(f: extern "Rust" fn(usize, ...)) {
+    //~^ ERROR: C-variadic functions with the "Rust" calling convention are not supported
+    f(22, 44);
+}
+
 extern "C" {
     fn foo(f: isize, x: u8, ...);
 }
diff --git a/tests/ui/c-variadic/variadic-ffi-1.stderr b/tests/ui/c-variadic/variadic-ffi-1.stderr
index a49fc0ce126..981b021276d 100644
--- a/tests/ui/c-variadic/variadic-ffi-1.stderr
+++ b/tests/ui/c-variadic/variadic-ffi-1.stderr
@@ -4,14 +4,20 @@ error[E0045]: C-variadic functions with the "stdcall" calling convention are not
 LL |     fn printf(_: *const u8, ...);
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
 
+error[E0045]: C-variadic functions with the "Rust" calling convention are not supported
+  --> $DIR/variadic-ffi-1.rs:15:11
+   |
+LL | fn baz(f: extern "Rust" fn(usize, ...)) {
+   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
+
 error[E0060]: this function takes at least 2 arguments but 0 arguments were supplied
-  --> $DIR/variadic-ffi-1.rs:23:9
+  --> $DIR/variadic-ffi-1.rs:28:9
    |
 LL |         foo();
    |         ^^^-- two arguments of type `isize` and `u8` are missing
    |
 note: function defined here
-  --> $DIR/variadic-ffi-1.rs:16:8
+  --> $DIR/variadic-ffi-1.rs:21:8
    |
 LL |     fn foo(f: isize, x: u8, ...);
    |        ^^^ -         -
@@ -21,13 +27,13 @@ LL |         foo(/* isize */, /* u8 */);
    |             +++++++++++++++++++++
 
 error[E0060]: this function takes at least 2 arguments but 1 argument was supplied
-  --> $DIR/variadic-ffi-1.rs:24:9
+  --> $DIR/variadic-ffi-1.rs:29:9
    |
 LL |         foo(1);
    |         ^^^--- argument #2 of type `u8` is missing
    |
 note: function defined here
-  --> $DIR/variadic-ffi-1.rs:16:8
+  --> $DIR/variadic-ffi-1.rs:21:8
    |
 LL |     fn foo(f: isize, x: u8, ...);
    |        ^^^           -
@@ -37,7 +43,7 @@ LL |         foo(1, /* u8 */);
    |              ++++++++++
 
 error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-1.rs:26:56
+  --> $DIR/variadic-ffi-1.rs:31:56
    |
 LL |         let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
    |                -------------------------------------   ^^^ expected non-variadic fn, found variadic function
@@ -48,7 +54,7 @@ LL |         let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
                  found fn item `unsafe extern "C" fn(_, _, ...) {foo}`
 
 error[E0308]: mismatched types
-  --> $DIR/variadic-ffi-1.rs:27:54
+  --> $DIR/variadic-ffi-1.rs:32:54
    |
 LL |         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
    |                -----------------------------------   ^^^ expected variadic fn, found non-variadic function
@@ -59,7 +65,7 @@ LL |         let y: extern "C" fn(f: isize, x: u8, ...) = bar;
                  found fn item `extern "C" fn(_, _) {bar}`
 
 error[E0617]: can't pass `f32` to variadic function
-  --> $DIR/variadic-ffi-1.rs:29:19
+  --> $DIR/variadic-ffi-1.rs:34:19
    |
 LL |         foo(1, 2, 3f32);
    |                   ^^^^
@@ -70,7 +76,7 @@ LL |         foo(1, 2, 3f32 as c_double);
    |                        +++++++++++
 
 error[E0617]: can't pass `bool` to variadic function
-  --> $DIR/variadic-ffi-1.rs:30:19
+  --> $DIR/variadic-ffi-1.rs:35:19
    |
 LL |         foo(1, 2, true);
    |                   ^^^^
@@ -81,7 +87,7 @@ LL |         foo(1, 2, true as c_int);
    |                        ++++++++
 
 error[E0617]: can't pass `i8` to variadic function
-  --> $DIR/variadic-ffi-1.rs:31:19
+  --> $DIR/variadic-ffi-1.rs:36:19
    |
 LL |         foo(1, 2, 1i8);
    |                   ^^^
@@ -92,7 +98,7 @@ LL |         foo(1, 2, 1i8 as c_int);
    |                       ++++++++
 
 error[E0617]: can't pass `u8` to variadic function
-  --> $DIR/variadic-ffi-1.rs:32:19
+  --> $DIR/variadic-ffi-1.rs:37:19
    |
 LL |         foo(1, 2, 1u8);
    |                   ^^^
@@ -103,7 +109,7 @@ LL |         foo(1, 2, 1u8 as c_uint);
    |                       +++++++++
 
 error[E0617]: can't pass `i16` to variadic function
-  --> $DIR/variadic-ffi-1.rs:33:19
+  --> $DIR/variadic-ffi-1.rs:38:19
    |
 LL |         foo(1, 2, 1i16);
    |                   ^^^^
@@ -114,7 +120,7 @@ LL |         foo(1, 2, 1i16 as c_int);
    |                        ++++++++
 
 error[E0617]: can't pass `u16` to variadic function
-  --> $DIR/variadic-ffi-1.rs:34:19
+  --> $DIR/variadic-ffi-1.rs:39:19
    |
 LL |         foo(1, 2, 1u16);
    |                   ^^^^
@@ -124,7 +130,7 @@ help: cast the value to `c_uint`
 LL |         foo(1, 2, 1u16 as c_uint);
    |                        +++++++++
 
-error: aborting due to 11 previous errors
+error: aborting due to 12 previous errors
 
 Some errors have detailed explanations: E0045, E0060, E0308, E0617.
 For more information about an error, try `rustc --explain E0045`.
diff --git a/tests/ui/c-variadic/variadic-ffi-2-arm.rs b/tests/ui/c-variadic/variadic-ffi-2-arm.rs
deleted file mode 100644
index 3b0a71007a0..00000000000
--- a/tests/ui/c-variadic/variadic-ffi-2-arm.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-//@ only-arm
-//@ build-pass
-#![feature(extended_varargs_abi_support)]
-
-fn aapcs(f: extern "aapcs" fn(usize, ...)) {
-    f(22, 44);
-}
-
-fn main() {}
diff --git a/tests/ui/c-variadic/variadic-ffi-2.rs b/tests/ui/c-variadic/variadic-ffi-2.rs
deleted file mode 100644
index adfd9bfa279..00000000000
--- a/tests/ui/c-variadic/variadic-ffi-2.rs
+++ /dev/null
@@ -1,28 +0,0 @@
-#![feature(extended_varargs_abi_support)]
-
-fn baz(f: extern "Rust" fn(usize, ...)) {
-    //~^ ERROR: C-variadic functions with the "Rust" calling convention are not supported
-    f(22, 44);
-}
-
-#[cfg(target_arch = "x86_64")]
-fn sysv(f: extern "sysv64" fn(usize, ...)) {
-    f(22, 44);
-}
-#[cfg(target_arch = "x86_64")]
-fn win(f: extern "win64" fn(usize, ...)) {
-    f(22, 44);
-}
-#[cfg(any(
-    target_arch = "arm",
-    target_arch = "aarch64",
-    target_arch = "riscv32",
-    target_arch = "riscv64",
-    target_arch = "x86",
-    target_arch = "x86_64"
-))]
-fn efiapi(f: extern "efiapi" fn(usize, ...)) {
-    f(22, 44);
-}
-
-fn main() {}
diff --git a/tests/ui/c-variadic/variadic-ffi-2.stderr b/tests/ui/c-variadic/variadic-ffi-2.stderr
deleted file mode 100644
index 2ac0a9f5ea2..00000000000
--- a/tests/ui/c-variadic/variadic-ffi-2.stderr
+++ /dev/null
@@ -1,9 +0,0 @@
-error[E0045]: C-variadic functions with the "Rust" calling convention are not supported
-  --> $DIR/variadic-ffi-2.rs:3:11
-   |
-LL | fn baz(f: extern "Rust" fn(usize, ...)) {
-   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
-
-error: aborting due to 1 previous error
-
-For more information about this error, try `rustc --explain E0045`.