about summary refs log tree commit diff
path: root/tests/ui/fn
diff options
context:
space:
mode:
authorJason Newcomb <jsnewcomb@pm.me>2025-02-06 14:06:15 -0500
committerJason Newcomb <jsnewcomb@pm.me>2025-02-06 16:06:03 -0500
commit2dd6dc1f8633e436ba3c4f23e376e60ffd135e68 (patch)
tree13cbf83049b45a74ec969d5f06009d010914faa7 /tests/ui/fn
parent79f82ad5e89aa421e2c765fea2098b23beb69b40 (diff)
downloadrust-2dd6dc1f8633e436ba3c4f23e376e60ffd135e68.tar.gz
rust-2dd6dc1f8633e436ba3c4f23e376e60ffd135e68.zip
Label mismatched parameters at the def site for foreign functions.
Diffstat (limited to 'tests/ui/fn')
-rw-r--r--tests/ui/fn/param-mismatch-foreign.rs11
-rw-r--r--tests/ui/fn/param-mismatch-foreign.stderr19
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/ui/fn/param-mismatch-foreign.rs b/tests/ui/fn/param-mismatch-foreign.rs
new file mode 100644
index 00000000000..2ab2bf95448
--- /dev/null
+++ b/tests/ui/fn/param-mismatch-foreign.rs
@@ -0,0 +1,11 @@
+extern "C" {
+    fn foo(x: i32, y: u32, z: i32);
+    //~^ NOTE function defined here
+}
+
+fn main() {
+    foo(1i32, 2i32);
+    //~^ ERROR this function takes 3 arguments but 2 arguments were supplied
+    //~| NOTE argument #2 of type `u32` is missing
+    //~| HELP provide the argument
+}
diff --git a/tests/ui/fn/param-mismatch-foreign.stderr b/tests/ui/fn/param-mismatch-foreign.stderr
new file mode 100644
index 00000000000..1182908891c
--- /dev/null
+++ b/tests/ui/fn/param-mismatch-foreign.stderr
@@ -0,0 +1,19 @@
+error[E0061]: this function takes 3 arguments but 2 arguments were supplied
+  --> $DIR/param-mismatch-foreign.rs:7:5
+   |
+LL |     foo(1i32, 2i32);
+   |     ^^^       ---- argument #2 of type `u32` is missing
+   |
+note: function defined here
+  --> $DIR/param-mismatch-foreign.rs:2:8
+   |
+LL |     fn foo(x: i32, y: u32, z: i32);
+   |        ^^^         -
+help: provide the argument
+   |
+LL |     foo(1i32, /* u32 */, 2i32);
+   |        ~~~~~~~~~~~~~~~~~~~~~~~
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0061`.