@@ -4,6 +4,79 @@ error[E0045]: C-variadic function must have C or cdecl calling convention
44LL | fn printf(_: *const u8, ...);
55 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadics require C or cdecl calling convention
66
7- error: aborting due to previous error
7+ error[E0060]: this function takes at least 2 parameters but 0 parameters were supplied
8+ --> $DIR/variadic-ffi-1.rs:16:9
9+ |
10+ LL | fn foo(f: isize, x: u8, ...);
11+ | ----------------------------- defined here
12+ ...
13+ LL | foo();
14+ | ^^^^^ expected at least 2 parameters
15+
16+ error[E0060]: this function takes at least 2 parameters but 1 parameter was supplied
17+ --> $DIR/variadic-ffi-1.rs:17:9
18+ |
19+ LL | fn foo(f: isize, x: u8, ...);
20+ | ----------------------------- defined here
21+ ...
22+ LL | foo(1);
23+ | ^^^^^^ expected at least 2 parameters
24+
25+ error[E0308]: mismatched types
26+ --> $DIR/variadic-ffi-1.rs:19:56
27+ |
28+ LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
29+ | ^^^ expected non-variadic fn, found variadic function
30+ |
31+ = note: expected type `unsafe extern "C" fn(isize, u8)`
32+ found type `for<'r> unsafe extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...) {foo}`
33+
34+ error[E0308]: mismatched types
35+ --> $DIR/variadic-ffi-1.rs:20:54
36+ |
37+ LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar;
38+ | ^^^ expected variadic fn, found non-variadic function
39+ |
40+ = note: expected type `for<'r> extern "C" fn(isize, u8, std::ffi::VaList<'r>, ...)`
41+ found type `extern "C" fn(isize, u8) {bar}`
42+
43+ error[E0617]: can't pass `f32` to variadic function
44+ --> $DIR/variadic-ffi-1.rs:22:19
45+ |
46+ LL | foo(1, 2, 3f32);
47+ | ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
48+
49+ error[E0617]: can't pass `bool` to variadic function
50+ --> $DIR/variadic-ffi-1.rs:23:19
51+ |
52+ LL | foo(1, 2, true);
53+ | ^^^^ help: cast the value to `c_int`: `true as c_int`
54+
55+ error[E0617]: can't pass `i8` to variadic function
56+ --> $DIR/variadic-ffi-1.rs:24:19
57+ |
58+ LL | foo(1, 2, 1i8);
59+ | ^^^ help: cast the value to `c_int`: `1i8 as c_int`
60+
61+ error[E0617]: can't pass `u8` to variadic function
62+ --> $DIR/variadic-ffi-1.rs:25:19
63+ |
64+ LL | foo(1, 2, 1u8);
65+ | ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
66+
67+ error[E0617]: can't pass `i16` to variadic function
68+ --> $DIR/variadic-ffi-1.rs:26:19
69+ |
70+ LL | foo(1, 2, 1i16);
71+ | ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
72+
73+ error[E0617]: can't pass `u16` to variadic function
74+ --> $DIR/variadic-ffi-1.rs:27:19
75+ |
76+ LL | foo(1, 2, 1u16);
77+ | ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
78+
79+ error: aborting due to 11 previous errors
880
9- For more information about this error, try `rustc --explain E0045`.
81+ Some errors have detailed explanations: E0045, E0060, E0308, E0617.
82+ For more information about an error, try `rustc --explain E0045`.
0 commit comments