Skip to content

Commit

Permalink
Add unit tests for the diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
Orion Gonzalez committed Nov 27, 2024
1 parent d83e320 commit c40651c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/ui/c-variadic/fn-item-diagnostic-issue-69232.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// https://github.com/rust-lang/rust/issues/69232

extern "C" {
fn foo(x: usize, ...);
}

fn test() -> u8 {
127
}

fn main() {
unsafe { foo(1, test) }; //~ ERROR can't pass a function item to a variadic function
}
12 changes: 12 additions & 0 deletions tests/ui/c-variadic/fn-item-diagnostic-issue-69232.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0617]: can't pass a function item to a variadic function
--> $DIR/issue-69232.rs:12:21
|
LL | unsafe { foo(1, test) };
| ^^^^ help: use a function pointer instead: `&test`
|
= help: a function item is zero-sized and needs to be casted into a pointer-sized 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

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0617`.

0 comments on commit c40651c

Please sign in to comment.