about summary refs log tree commit diff
path: root/tests/ui/error-codes
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-11-29 10:18:59 +0100
committerGitHub <noreply@github.com>2024-11-29 10:18:59 +0100
commit72cf40d9edd4d8172f5e1ff58f6cafe9734b2e2a (patch)
treeddf179c940af8b0cba63ccc98af99af99f92caee /tests/ui/error-codes
parent8ca5a907a506c541a449c533fcb705b9a008361b (diff)
parent1e4817cd33a59f1e0ddb1a3e66bdc0794d0785be (diff)
downloadrust-72cf40d9edd4d8172f5e1ff58f6cafe9734b2e2a.tar.gz
rust-72cf40d9edd4d8172f5e1ff58f6cafe9734b2e2a.zip
Rollup merge of #133538 - dev-ardi:69232-better-diag, r=compiler-errors
Better diagnostic for fn items in variadic functions

closes #69232
Diffstat (limited to 'tests/ui/error-codes')
-rw-r--r--tests/ui/error-codes/E0617.rs5
-rw-r--r--tests/ui/error-codes/E0617.stderr8
2 files changed, 8 insertions, 5 deletions
diff --git a/tests/ui/error-codes/E0617.rs b/tests/ui/error-codes/E0617.rs
index b71ba0ed88b..4a38174bc6f 100644
--- a/tests/ui/error-codes/E0617.rs
+++ b/tests/ui/error-codes/E0617.rs
@@ -20,7 +20,8 @@ fn main() {
         //~^ ERROR can't pass `u16` to variadic function
         //~| HELP cast the value to `c_uint`
         printf(::std::ptr::null(), printf);
-        //~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
-        //~| HELP cast the value to `unsafe extern "C" fn(*const i8, ...)`
+        //~^ ERROR can't pass a function item to a variadic function
+        //~| HELP a function item is zero-sized and needs to be cast into a function pointer to be used in FFI
+        //~| HELP use a function pointer instead
     }
 }
diff --git a/tests/ui/error-codes/E0617.stderr b/tests/ui/error-codes/E0617.stderr
index ea91ad08292..7193463e028 100644
--- a/tests/ui/error-codes/E0617.stderr
+++ b/tests/ui/error-codes/E0617.stderr
@@ -28,16 +28,18 @@ error[E0617]: can't pass `u16` to variadic function
 LL |         printf(::std::ptr::null(), 0u16);
    |                                    ^^^^ help: cast the value to `c_uint`: `0u16 as c_uint`
 
-error[E0617]: can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
+error[E0617]: can't pass a function item to a variadic function
   --> $DIR/E0617.rs:22:36
    |
 LL |         printf(::std::ptr::null(), printf);
    |                                    ^^^^^^
    |
-help: cast the value to `unsafe extern "C" fn(*const i8, ...)`
+   = help: a function item is zero-sized and needs to be cast into a function pointer to be used in FFI
+   = note: for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html
+help: use a function pointer instead
    |
 LL |         printf(::std::ptr::null(), printf as unsafe extern "C" fn(*const i8, ...));
-   |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+   |                                           +++++++++++++++++++++++++++++++++++++++
 
 error: aborting due to 6 previous errors