Skip to content

Commit c40651c

Browse files
author
Orion Gonzalez
committed
Add unit tests for the diagnostic
1 parent d83e320 commit c40651c

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// https://github.com/rust-lang/rust/issues/69232
2+
3+
extern "C" {
4+
fn foo(x: usize, ...);
5+
}
6+
7+
fn test() -> u8 {
8+
127
9+
}
10+
11+
fn main() {
12+
unsafe { foo(1, test) }; //~ ERROR can't pass a function item to a variadic function
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0617]: can't pass a function item to a variadic function
2+
--> $DIR/issue-69232.rs:12:21
3+
|
4+
LL | unsafe { foo(1, test) };
5+
| ^^^^ help: use a function pointer instead: `&test`
6+
|
7+
= help: a function item is zero-sized and needs to be casted into a pointer-sized function pointer to be used in FFI
8+
= note: for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0617`.

0 commit comments

Comments
 (0)