diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-11-29 10:18:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-29 10:18:59 +0100 |
| commit | 72cf40d9edd4d8172f5e1ff58f6cafe9734b2e2a (patch) | |
| tree | ddf179c940af8b0cba63ccc98af99af99f92caee /tests/ui/error-codes | |
| parent | 8ca5a907a506c541a449c533fcb705b9a008361b (diff) | |
| parent | 1e4817cd33a59f1e0ddb1a3e66bdc0794d0785be (diff) | |
| download | rust-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.rs | 5 | ||||
| -rw-r--r-- | tests/ui/error-codes/E0617.stderr | 8 |
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 |
